# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344072 | 2021-01-05T05:48:35 Z | Nurlykhan | Red-blue table (IZhO19_stones) | C++17 | 45 ms | 1388 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 && j <= m / 2) 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 && i == n - 1 && j <= m / 2) printf("-"); else printf("+"); } printf("\n"); } } } int main() { scanf("%d", &t); while (t--) { scanf("%d%d", &n, &m); // printf("Slow:\n"); // solve(); // printf("Tupo:\n"); tupo(); // printf("\n-------------\n"); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 0 ms | 364 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 0 ms | 364 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 45 ms | 1388 KB | in the table A+B is not equal to 98 |
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 | 364 KB | Output is correct |
2 | Incorrect | 0 ms | 364 KB | in the table A+B is not equal to 5 |