QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#320393 | #8217. King's Dinner | ucup-team2112# | WA | 1ms | 3844kb | C++20 | 4.4kb | 2024-02-03 16:20:49 | 2024-02-03 16:20:50 |
Judging History
answer
// #include <bits/stdc++.h>
// bool vis[100][100];
// bool ans[100][100];
// int n;
// int res;
// std::pair<int, int> nxt(int x, int y) {
// if (y == n) return {x + 1, 1};
// return {x, y + 1};
// }
// bool check(int x, int y) {
// for (auto dx : {-1, 0, 1}) {
// for (auto dy : {-1, 0, 1}) {
// if (x + dx >= 1 && x + dx <= n && y + dy >= 1 && y + dy <= n) {
// if (vis[x + dx][y + dy]) return false;
// }
// }
// }
// return true;
// }
// void dfs(int x, int y, int cur) {
// if (x == n && y == n) {
// if (cur > res) {
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= n; j++) {
// ans[i][j] = vis[i][j];
// }
// }
// }
// res = std::max(res, cur);
// return;
// }
// auto [nx, ny] = nxt(x, y);
// if (y + 1 <= n && check(x, y) && check(x, y + 1)){
// vis[x][y] = vis[x][y + 1] = true;
// dfs(nx, ny, cur + 1);
// vis[x][y] = vis[x][y + 1] = false;
// }
// if (x + 1 <= n && check(x, y) && check(x + 1, y)){
// vis[x][y] = vis[x + 1][y] = true;
// dfs(nx, ny, cur + 1);
// vis[x][y] = vis[x + 1][y] = false;
// }
// dfs(nx, ny, cur);
// }
// int main(){
// std::ios::sync_with_stdio(false);
// std::cin.tie(nullptr);
// std::cout.tie(nullptr);
// for (int i = 8; i <= 9; i += 1) {
// n = i;
// res = 0;
// dfs(1, 1, 0);
// std::cout << n << " " << res << '\n';
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= n; j++) {
// std::cout << (ans[i][j] ? 'o': '.');
// }
// std::cout << '\n';
// }
// }
// return 0;
// }
#include <bits/stdc++.h>
int res[1000][1000];
int n;
void output(){
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
std::cout << (res[i][j] ? '#': '.');
}
std::cout << '\n';
}
}
void solve(){
std::cin >> n;
if (n % 6 == 0) {
for (int i = 1; i + 2 <= n; i += 2) {
for (int j = 1; j + 4 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
for (int i = 1; i + 3 <= n; i += 2) {
res[n - 1][i] = res[n][i] = 1;
}
for (int i = 1; i + 4 <= n; i += 3) {
res[i][n - 2] = res[i][n] = 1;
res[i + 1][n - 2] = res[i + 1][n] = 1;
}
res[n][n] = res[n][n - 1] = 1;
res[n - 2][n] = res[n - 2][n - 1] = 1;
}
if (n % 6 == 4) {
for (int i = 1; i + 2 <= n; i += 2) {
for (int j = 1; j + 3 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
for (int i = 1; i + 3 <= n; i += 2) {
res[n - 1][i] = res[n][i] = 1;
}
for (int i = 1; i + 3 <= n; i += 3) {
res[i][n] = res[i + 1][n] = 1;
}
res[n][n] = res[n][n - 1] = 1;
}
if (n % 6 == 5) {
for (int i = 1; i <= n; i += 2) {
for (int j = 1; j + 1 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
}
if (n % 6 == 2) {
for (int i = 1; i + 2 <= n; i += 2) {
for (int j = 1; j + 1 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
for (int i = 1; i <= n; i += 2) {
res[n - 1][i] = res[n][i] = 1;
}
}
if (n % 6 == 1) {
for (int i = 1; i <= n; i += 2) {
for (int j = 1; j + 1 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
for (int i = 1; i + 1 <= n; i += 3) {
res[i][n] = res[i + 1][n] = 1;
}
}
if (n % 6 == 3) {
for (int i = 1; i <= n; i += 2) {
for (int j = 1; j + 3 <= n; j += 3) {
res[i][j] = res[i][j + 1] = 1;
}
}
for (int i = 1; i + 1 <= n; i += 3) {
res[i][n - 2] = res[i][n] = 1;
res[i + 1][n - 2] = res[i + 1][n] = 1;
}
}
output();
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout.tie(nullptr);
int T;
std::cin >> T;
while(T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3712kb
input:
3 1 2 3
output:
. #. #. #.# #.# ...
result:
ok all tests correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3844kb
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 grid contains two dominoes that are adjacent (test case 4)