10 月 5 日模拟赛总结
Before
预期
实际
挂分
rk21,直接垫底。菜死了
为什么会挂
T1
Description
求
输入一行两个整数
输出第一行一个整数
Solution
直接开个标记数组标记不超过范围的 pow
,然后
当然也可以
Q:
那你为什么保龄了?
A:
没有输出上文 Description
中加粗的输入中的
考场想法:模拟。
考场寄因:如上。
时间复杂度
Code
// 2023/10/5 PikachuQAQ
#include <iostream>
#include <cmath>
using namespace std;
int l, r, b[3000000], cnt;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> l >> r;
for (int i = 0; i <= 20; i++) {
int x = pow(2, i);
b[x] = 1;
}
for (int i = l; i <= r; i++) {
cnt += b[i];
}
cout << cnt << '\n';
for (int i = l; i <= r; i++) {
if (b[i]) {
cout << i << ' ';
}
}
return 0;
}
// 2023/10/5 PikachuQAQ
#include <iostream>
#include <cmath>
using namespace std;
int l, r, b[3000000];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> l >> r;
for (int i = 0; i <= 20; i++) {
int x = pow(2, i);
b[x] = 1;
}
for (int i = l; i <= r; i++) {
if (b[i]) {
cout << i << ' ';
}
}
return 0;
}
T2
Description
给定
输入一行两个整数
输出 No
。
Solution
开题 20min
首先写了个字典树,但发现字典树不会写了数据范围很小,所以可以直接暴力增删改,然后直接匹配即可。亦可以直接字典树,但比较麻烦。
Q:
那你为什么保龄了?
A:
没有输出上文 Description
中加粗的输出 No
,我输出了 NO
。因为读题不仔细又痛失
考场想法:暴力匹配。
考场寄因:如上。
时间复杂度
Code
// 2023/10/5 PikachuQAQ
#include <iostream>
using namespace std;
const int kMaxN = 57, INF = 100;
int n, q;
string a[kMaxN], b;
string substr(string s, int l) {
string res = "";
for (int i = 0; i < s.length(); i++) {
if (i ^ l) {
res += s[i];
}
}
return res;
}
string insert(string s, int x, char c) {
string res = "";
int r = s.length() + (x == s.length());
for (int i = 0; i < r; i++) {
if (i ^ x) {
res += s[i];
} else {
res += c;
if (i < s.length()) {
res += s[i];
}
}
}
return res;
}
int match(string a, string b) {
if (a == b) {
return 0;
}
string f = b;
int ln = b.length();
for (int i = 0; i <= ln; i++) {
for (int j = 'a'; j <= 'z'; j++) {
f = insert(f, i, j);
if (f == a) {
return 1;
}
f = b;
}
}
for (int i = 0; i < ln; i++) {
if (substr(f, i) == a) {
return 1;
}
}
for (int i = 0; i < ln; i++) {
for (int j = 'a'; j <= 'z'; j++) {
f[i] = j;
if (f == a) {
return 1;
}
}
f = b;
}
return -1;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1, sol; i <= q; i++) {
cin >> b;
for (int j = 1; j <= n; j++) {
if (match(a[j], b) != -1) {
sol = 1;
cout << a[j] << '\n';
break;
}
}
if (sol == 0) {
cout << "No\n";
}
sol = 0;
}
return 0;
}
// 2023/10/5 PikachuQAQ
#include <iostream>
using namespace std;
const int kMaxN = 57, INF = 100;
int n, q;
string a[kMaxN], b;
string substr(string s, int l) {
string res = "";
for (int i = 0; i < s.length(); i++) {
if (i ^ l) {
res += s[i];
}
}
return res;
}
string insert(string s, int x, char c) {
string res = "";
int r = s.length() + (x == s.length());
for (int i = 0; i < r; i++) {
if (i ^ x) {
res += s[i];
} else {
res += c;
if (i < s.length()) {
res += s[i];
}
}
}
return res;
}
int match(string a, string b) {
if (a == b) {
return 0;
}
string f = b;
int ln = b.length();
for (int i = 0; i <= ln; i++) {
for (int j = 'a'; j <= 'z'; j++) {
f = insert(f, i, j);
if (f == a) {
return 1;
}
f = b;
}
}
for (int i = 0; i < ln; i++) {
if (substr(f, i) == a) {
return 1;
}
}
for (int i = 0; i < ln; i++) {
for (int j = 'a'; j <= 'z'; j++) {
f[i] = j;
if (f == a) {
return 1;
}
}
f = b;
}
return -1;
}
int main() {
freopen("dict.in", "r", stdin);
freopen("dict.out", "w", stdout);
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> q;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1, sol; i <= q; i++) {
cin >> b;
for (int j = 1; j <= n; j++) {
if (match(a[j], b) != -1) {
sol = 1;
cout << a[j] << '\n';
break;
}
}
if (sol == 0) {
cout << "No\n";
}
sol = 0;
}
return 0;
}
T3
Description
Solution
Code
T4
Description
Solution
Code
Summary
需要掌握的:仔细读题。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现