前言
我恨模拟
正文
| T1 | T2 | T3 | T4 | 总分 | |
|---|---|---|---|---|---|
| 估分 | 100 | 100 | 50 | 30 | 280 |
| 实际得分 | 65 | 100 | 50 | 30 | 245 |
T1
本来就是一道普普通通的模拟题,结果没判断 的情况(导致最后多输出一个换行)。幸亏不是捆绑
赛时代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, x;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> x;
cout << "+---------------------+\n";
cout << "|";
for (int i = 1; i < x; i++) cout << "...";
for (int i = 1; i <= n; i++) {
if (i < 10) cout << ".." << i;
else cout << "." << i;
if ((i + x - 1) % 7 == 0) cout << "|\n|";
}
for (int i = n; (i + x - 1) % 7 != 0; i++) cout << "...";
cout << "|\n+---------------------+";
return 0;
}ac代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, x;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n >> x;
cout << "+---------------------+\n";
cout << "|";
for (int i = 1; i <= n + x - 1; i++) {
if (i >= x && i - x + 1 < 10) cout << ".." << i - x + 1;
else if (i < x) cout << "...";
else cout << "." << i - x + 1;
if (i % 7 == 0 && i != n + x - 1) cout << "|\n|";
}
for (int i = n; (i + x - 1) % 7 != 0; i++) cout << "...";
cout << "|\n+---------------------+";
return 0;
}T2
又是一道模拟。 按行,列,块去枚举一下有没有重复就行了。 我的小长代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int vis[15], f;
vector<int> a[15];
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
for (int i = 1; i <= 9; i++) {
string s;
cin >> s;
if (s[1] == '-') {
i--;
continue;
}
a[i].push_back(0);
for (int j = 0; j < s.size(); j++) {
if (s[j] == '|') continue;
if (s[j] == '.') a[i].push_back(0);
else a[i].push_back(s[j] - '0');
}
}
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) vis[j] = 0;
for (int j = 1; j <= 9; j++) {
// cout << a[i][j] << " ";
if (a[i][j] == 0) continue;
if (vis[a[i][j]]) f = 1;
vis[a[i][j]] = 1;
}
// cout << "\n";
}
for (int i = 1; i <= 9; i++) {
for (int j = 1; j <= 9; j++) vis[j] = 0;
for (int j = 1; j <= 9; j++) {
if (a[j][i] == 0) continue;
if (vis[a[j][i]]) f = 1;
vis[a[j][i]] = 1;
}
}
for (int i = 1; i <= 9; i += 3) {
for (int j = 1; j <= 9; j += 3) {
for (int j = 1; j <= 9; j++) vis[j] = 0;
for (int x = i; x <= i + 2; x++) {
for (int y = j; y <= j + 2; y++) {
if (a[x][y] == 0) continue;
if (vis[a[x][y]]) f = 1;
vis[a[x][y]] = 1;
}
}
}
}
if (f) cout << "GRESKA";
else cout << "OK";
return 0;
}T3
想不到是dp,骗了50分。 代码:略
T4
二维st表和线段树维护每一行,都不晓得打。最后30分钟,打了个暴力…… 代码:略