# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169413 | 2019-12-20T09:20:41 Z | SamAnd | Red-blue table (IZhO19_stones) | C++17 | 25 ms | 1616 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); if (n > m) { for (int i = 0; i < n; ++i) { int q = 0; for (int j = 0; j < m; ++j) { if (q * 2 <= m) { a[i][j] = '+'; ++q; } else a[i][j] = '-'; } } } else { for (int j = 0; j < m; ++j) { int q = 0; for (int i = 0; i < n; ++i) { if (q * 2 <= n) { a[i][j] = '-'; ++q; } else a[i][j] = '+'; } } } ubd(); 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 | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Incorrect | 3 ms | 504 KB | Wrong answer in test 5 29: 31 < 32 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 25 ms | 1528 KB | Wrong answer in test 97 21: 107 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 1616 KB | Wrong answer in test 24 24: 35 < 44 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Incorrect | 3 ms | 504 KB | Wrong answer in test 5 29: 31 < 32 |