QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#471892 | #4325. Kraljice | PorNPtree | 0 | 0ms | 3796kb | C++17 | 1.3kb | 2024-07-11 11:03:09 | 2024-07-11 11:03:10 |
answer
#include <bits/stdc++.h>
using namespace std;
vector< pair<int, int> > res;
const int N = 1100;
int c1[N], c2[N], c3[N + N], c4[N + N], vis[N][N];
void o(int x, int y) {
if ((c1[x] ^ c2[y] ^ c3[x + y] ^ c4[x - y + N]) || vis[x][y]) return;
res.push_back({x, y});
c1[x] ^= 1, c2[y] ^= 1, c3[x + y] ^= 1, c4[x - y + N] ^= 1, vis[x][y] = 1;
}
void solve(int n) {
if (n <= 2) { o(1, 1); return;}
if (n & 1) {
solve(n - 2);
for (int i = 1; i <= n - 3; ++i) o(i, n - 1), o(i, n), o(i, n - 1), o(n - 1, i), o(n, i), o(n - 1, i);
o(n - 1, n), o(n - 1, n - 1), o(n, n - 2), o(n - 2, n), o(n - 2, n - 1), o(n, n - 1), o(n - 1, n - 2), o(n, n);
return;
}
solve(n - 3);
o(n - 1, n);
for (int j = 1; j <= 3; ++j) for (int i = 1; i <= n - 3; ++i) {
o(i, n), o(n, i), o(i, n), o(i, n - 1), o(n - 1, i), o(i, n - 1), o(i, n - 2), o(n - 2, i), o(i, n - 2);
}
o(n - 2, n), o(n - 2, n - 2), o(n, n - 1), o(n - 1, n - 2), o(n - 1, n - 1), o(n, n);
}
signed main() {
int n; scanf("%d", &n);
solve(n);
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= n; ++j) putchar(vis[i][j] + '0');
puts("");
}
printf("%d\n", (int)res.size());
for (auto x : res) printf("%d %d\n", x.first, x.second);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
1
output:
1 1 1 1
result:
wrong output format Extra information in the output file
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%