# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169412 | 2019-12-20T09:12:37 Z | SamAnd | Red-blue table (IZhO19_stones) | C++17 | 2000 ms | 632 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1003; int n, m; int ans; char uans[N][N]; char a[N][N]; void ubd() { int yans = 0; for (int i = 0; i < n; ++i) { int q = 0; for (int j = 0; j < m; ++j) { if (a[i][j] == '+') ++q; } if (q * 2 > m) ++yans; } for (int j = 0; j < m; ++j) { int q = 0; for (int i = 0; i < n; ++i) { if (a[i][j] == '-') ++q; } if (q * 2 > n) ++yans; } if (yans > ans) { ans = yans; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) uans[i][j] = a[i][j]; } } void rec(int i, int j) { if (i == n) { ubd(); return; } a[i][j] = '+'; if (j == m - 1) rec(i + 1, 0); else rec(i, j + 1); a[i][j] = '-'; if (j == m - 1) rec(i + 1, 0); else rec(i, j + 1); } void solv() { scanf("%d%d", &n, &m); ans = 0; rec(0, 0); printf("%d\n", ans); for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) putchar(uans[i][j]); putchar('\n'); } } int main() { int tt; scanf("%d", &tt); while (tt--) solv(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2059 ms | 256 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Execution timed out | 2059 ms | 256 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2051 ms | 632 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2061 ms | 376 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 348 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Execution timed out | 2059 ms | 256 KB | Time limit exceeded |