# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344076 | 2021-01-05T06:04:08 Z | Nurlykhan | Red-blue table (IZhO19_stones) | C++17 | 44 ms | 1392 KB |
#include <bits/stdc++.h> using namespace std; const int N = 1024; int t; int n, m; bool a[N][N], ans[N][N]; int cnt() { int res = 0; for (int i = 0; i < n; i++) { int s = 0; for (int j = 0; j < m; j++) { if (a[i][j]) s++; else s--; } if (s > 0) res++; } for (int j = 0; j < m; j++) { int s = 0; for (int i = 0; i < n; i++) { if (a[i][j]) s++; else s--; } if (s < 0) res++; } return res; } void solve() { int mx = 0; for (int mask = 0; mask < (1 << (n * m)); mask++) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if ((mask >> (i * m + j)) % 2) { a[i][j] = 1; } else { a[i][j] = 0; } } } int cur = cnt(); if (cur > mx) { mx = cur; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { ans[i][j] = a[i][j]; } } } } printf("%d\n", mx); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (ans[i][j]) printf("+"); else printf("-"); } printf("\n"); } } void tupo() { if (n <= m) { bool boo = 1; int ans = m + 1; if (n <= 2) { boo = 0; ans = m; } printf("%d\n", ans); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (boo && i == 0) printf("+"); else printf("-"); } printf("\n"); } } else { bool boo = 1; int ans = n + 1; if (m <= 2) { boo = 0; ans = n; } printf("%d\n", ans); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (boo && j == m - 1) printf("-"); else printf("+"); } printf("\n"); } } } int main() { scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); tupo(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Incorrect | 3 ms | 364 KB | Wrong answer in test 5 29: 30 < 32 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 44 ms | 1392 KB | Wrong answer in test 97 21: 98 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 41 ms | 1388 KB | Wrong answer in test 24 24: 25 < 44 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 364 KB | Output is correct |
4 | Incorrect | 3 ms | 364 KB | Wrong answer in test 5 29: 30 < 32 |