QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#320375 | #8217. King's Dinner | ucup-team1303# | WA | 2ms | 3628kb | C++20 | 2.3kb | 2024-02-03 16:13:27 | 2024-02-03 16:13:28 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T &x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
}
const int N = 110;
int n;
char a[N][N];
bool check1(int x, int y) {
if (x == n) return false;
F(i, max(1, x - 1), min(n, x + 2))
F(j, max(1, y - 1), min(n, y + 1))
if (a[i][j] == '#') return false;
// if (a[x][y] == '#') return false;
// if (a[x + 1][y] == '#') return false;
// if (y > 1 && a[x - 1][y - 1] == '#') return false;
// if (y > 1 && a[x][y - 1] == '#') return false;
// if (y > 1 && a[x + 1][y - 1] == '#') return false;
// if (y < n && a[x][y + 1] == '#') return false;
// if (y < n && a[x + 1][y + 1] == '#') return false;
return true;
}
bool check2(int x, int y) {
if (y == n) return false;
F(i, max(1, x - 1), min(n, x + 1))
F(j, max(1, y - 1), min(n, y + 2))
if (a[i][j] == '#') return false;
return true;
}
void work1(int i, int j) {//竖
if (check1(i, j)) {
a[i][j] = a[i + 1][j] = '#';
}
}
void work2(int i, int j) {//横
if (check2(i, j)) {
a[i][j] = a[i][j + 1] = '#';
}
}
void zhk() {
cin >> n;
F(i, 1, n)
F(j, 1, n)
a[i][j] = '.';
F(i, 1, n) {
F(j, 1, n) {
work1(j, i);
}
F(j, 1, n) {
work2(i, j);
}
F(j, 1, n) {
work1(j, n - i + 1);
}
F(j, 1, n) {
work2(n - i + 1, j);
}
}
// F(i, 1, n) {
// F(j, 1, n) {
// if (check1(i, j)) {
// a[i][j] = a[i + 1][j] = '#';
// }
// }
// }
// F(i, 1, n) {
// F(j, 1, n) {
// if (check2(i, j)) {
// a[i][j] = a[i][j + 1] = '#';
// }
// }
// }
F(i, 1, n) {
F(j, 1, n)
cout << a[i][j];
cout << '\n';
}
}
signed main() {
int _ = 1;
cin >> _;
while (_--) zhk();
return 0;
}
/* why?
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3528kb
input:
3 1 2 3
output:
. #. #. #.# #.# ...
result:
ok all tests correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3628kb
input:
50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
output:
. #. #. #.# #.# ... #.## #... ...# ##.# #.##. #.... ..#.# #.#.# #.... #.##.# #....# ..#... #.#..# #....# ..##.. #.##.## #...... ..#.#.# #.#.#.# #...... ......# ##.##.# #.##.##. #....... ..#.##.# #.#....# #....#.. ..##.#.# #......# #.##.... #.##.##.# #.......# ..#.##... #.#.....# #...#.#.# ..#.#.#.. ...
result:
wrong answer jury has the better answer: jans = 6, pans = 5 (test case 5)