10 月 5 日模拟赛总结
PikachuQAQ · · 个人记录
Before
本文章在博客园同步发布
Contest-Link
预期
实际
挂分
rk21,直接垫底。菜死了
为什么会挂
T1
Description
求
输入一行两个整数
输出第一行一个整数
// 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。
// 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
需要掌握的:仔细读题。