# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395743 | 2021-04-28T20:15:08 Z | ly20 | Red-blue table (IZhO19_stones) | C++17 | 69 ms | 1844 KB |
#include <bits/stdc++.h> using namespace std; const int MAXN = 1123; int tb[MAXN][MAXN]; int sl[MAXN], sc[MAXN]; int n, m; bool teste(int a, int b) { if(a > n || b > m) return false; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { tb[i][j] = 0; sl[i] = m; sc[j] = 0; } } bool ok = true; for(int i = n; i > n - a; i--) { for(int j = 1; j <= m; j++) { tb[i][j] = 1; sl[i]--; sc[j]++; } } for(int j = m; j > m - a; j--) { for(int i = n; i >= 1; i--) { tb[i][j] = 0; sl[i]++; sc[j]--; } } int l = n - a, c = m - b; int liml = m / 2 + 1, limc = n / 2 + 1; if(l == 0 || c == 0) return true; for(int i = 1; i <= l; i++) { int qtdisp = sl[i] - liml; for(int j = 1; j <= c; j++) { if(qtdisp > 0 && sc[j] < limc) { qtdisp--; sc[j]++; tb[i][j] = 1; sl[i]--; } } } for(int i = 1; i <= c; i++) if(sc[i] < limc) ok = false; return ok; } int main() { int t; scanf("%d", &t); while(t--) { scanf("%d %d", &n, &m); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { tb[i][j] = 0; sl[i] = m; sc[j] = 0; } } if(n == 1) { printf("%d\n", m); for(int i = 0; i < m; i++) printf("-"); printf("\n"); continue; } else if(m == 1) { printf("%d\n", n); for(int i = 0; i < n; i++) printf("+\n"); continue; } bool ok = false; int resp = 0; for(int i = 1; i < 5; i++) { for(int j = 0; j <= i; j++) { if(ok) continue; ok = teste(j, i - j); if(ok) resp = i; } } printf("%d\n", m + n - resp); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { if(tb[i][j] == 0) printf("+"); else printf("-"); } printf("\n"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | in the table A+B is not equal to 4 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 460 KB | in the table A+B is not equal to 46 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | in the table A+B is not equal to 4 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 56 ms | 1728 KB | in the table A+B is not equal to 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 69 ms | 1844 KB | in the table A+B is not equal to 44 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | in the table A+B is not equal to 4 |