# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395751 | 2021-04-28T20:29:13 Z | ly20 | Red-blue table (IZhO19_stones) | C++17 | 69 ms | 5304 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 j = m; j > m - b; j--) { for(int i = n; i >= 1; i--) { tb[i][j] = 0; sc[j] = 0; } } for(int i = n; i > n - a; i--) { for(int j = 1; j <= m; j++) { tb[i][j] = 1; 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; //if(a == 0 && b == 1) printf("%d %d\n", qtdisp, i); 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 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Incorrect | 3 ms | 460 KB | Wrong answer in test 38 5: 40 < 41 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 1708 KB | Output is correct |
2 | Correct | 60 ms | 4468 KB | Output is correct |
3 | Correct | 48 ms | 5304 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 69 ms | 1880 KB | Output is correct |
2 | Correct | 52 ms | 4164 KB | Output is correct |
3 | Correct | 48 ms | 3500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 2 ms | 460 KB | Output is correct |
4 | Incorrect | 3 ms | 460 KB | Wrong answer in test 38 5: 40 < 41 |