QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#320479 | #8217. King's Dinner | ucup-team1303# | AC ✓ | 9ms | 3796kb | C++20 | 5.3kb | 2024-02-03 17:13:07 | 2024-02-03 17:13:09 |
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;
}
bool work1(int i, int j) {//竖
if (check1(i, j)) {
a[i][j] = a[i + 1][j] = '#';
return true;
}
return false;
}
bool work2(int i, int j) {//横
if (check2(i, j)) {
// debug << i << " " << j << endl;
a[i][j] = a[i][j + 1] = '#';
return true;
}
return false;
}
const string biao[] = {
"#.#.##.#",
"#.#....#",
"....##..",
"#......#",
"#.##.#.#",
".....#..",
"#.#....#",
"#.#.##.#"};
// void solve(int l, int r) {
// debug << l << " " << r << endl;
// if (r - l + 1 == 8) {
// F(i, l, r)
// F(j, l, r)
// a[i][j] = biao[i - l][j - l];
// return;
// }
// while (true) {
// bool flag = true;
// F(j, l, r) {
// if (work1(j, l)) {
// flag = false;
// break;
// }
// }
// DF(j, n, 1) {
// if (work1(j, r)) {
// flag = false;
// break;
// }
// }
// DF(j, n, 1) {
// // debug << i << " " << j << endl;
// if (work2(l, j)) {
// flag = false;
// break;
// }
// }
// F(j, 1, n) {
// if (work2(r, j)) {
// flag = false;
// break;
// }
// }
// if (flag) break;
// }
// solve(l + 2, r - 2);
// }
void zhk() {
cin >> n;
F(i, 1, n)
F(j, 1, n)
a[i][j] = '.';
if (n % 6 == 5) {
F(i, 1, n) {
F(j, 1, n) {
if (i % 3 && (j & 1)) cout << '#';
else cout << '.';
}
cout << '\n';
}
return;
}
if (n >= 8) {
if (n % 6 == 2) {
// F(i, 1, n) {
// while (true) {
// bool flag = true;
// F(j, 1, n) {
// if (work1(j, i)) {
// flag = false;
// break;
// }
// }
// DF(j, n, 1) {
// if (work1(j, n - i + 1)) {
// flag = false;
// break;
// }
// }
// DF(j, n, 1) {
// // debug << i << " " << j << endl;
// if (work2(i, j)) {
// flag = false;
// break;
// }
// }
// F(j, 1, n) {
// if (work2(n - i + 1, j)) {
// flag = false;
// break;
// }
// }
// if (flag) break;
// }
// // if (i == 1) {
// // F(i, 1, n) {
// // F(j, 1, n)
// // cout << a[i][j];
// // cout << '\n';
// // }
// // debug << endl;
// // }
// }
// debug << "!\n";
// solve(1, n);
F(i, 1, 8)
F(j, 1, 8)
a[i][j] = biao[i - 1][j - 1];
F(i, 1, 8) if (i % 3) {
F(j, 9, n) {
if (j % 2 == 0) a[i][j] = '#';
}
}
F(i, 9, n) if (i % 2 == 0) {
F(j, 1, n) if (j % 3) {
a[i][j] = '#';
}
}
// for (int i = 8; i < n; i += 6) {
// F(j, )
// }
F(i, 1, n) {
F(j, 1, n)
cout << a[i][j];
cout << '\n';
}
return;
}
}
// if (n == 8) {
// puts("#.#.##.#\n#.#....#\n....##..\n#......#\n#.##.#.#\n.....#..\n#.#....#\n#.#.##.#");
// return;
// }
F(i, 1, n) {
while (true) {
bool flag = true;
F(j, 1, n) {
if (work1(j, i)) {
flag = false;
break;
}
}
DF(j, n, 1) {
if (work1(j, n - i + 1)) {
flag = false;
break;
}
}
DF(j, n, 1) {
// debug << i << " " << j << endl;
if (work2(i, j)) {
flag = false;
break;
}
}
F(j, 1, n) {
if (work2(n - i + 1, j)) {
flag = false;
break;
}
}
if (flag) break;
}
// if (i == 1) {
// F(i, 1, n) {
// F(j, 1, n)
// cout << a[i][j];
// cout << '\n';
// }
// debug << endl;
// }
}
// 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?
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
input:
3 1 2 3
output:
. #. #. #.. #.# ..#
result:
ok all tests correct (3 test cases)
Test #2:
score: 0
Accepted
time: 2ms
memory: 3588kb
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:
ok all tests correct (50 test cases)
Test #3:
score: 0
Accepted
time: 9ms
memory: 3796kb
input:
39 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
output:
#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## #.#................................................ ....##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## #.#................................................ #.#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.#.# ....#......................................
result:
ok all tests correct (39 test cases)
Test #4:
score: 0
Accepted
time: 3ms
memory: 3564kb
input:
11 90 91 92 93 94 95 96 97 98 99 100
output:
#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## #.#....................................................................................... ....##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## #.#...........................
result:
ok all tests correct (11 test cases)
Test #5:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
1 100
output:
#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.## #................................................................................................... ..#.#.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##.##...
result:
ok all tests correct (1 test case)
Extra Test:
score: 0
Extra Test Passed