# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202988 | 2020-02-18T21:52:57 Z | luciocf | Red-blue table (IZhO19_stones) | C++14 | 80 ms | 1912 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 1e3+10; struct S { int ind, qtd; } col[maxn]; char tab[maxn][maxn]; bool comp(S a, S b) {return a.qtd > b.qtd;} int main(void) { int t; scanf("%d", &t); while (t--) { int n, m; scanf("%d %d", &n, &m); for (int i = 1; i <= m; i++) col[i] = {i, n}; int mx = m, opt = 0; int tot = m; for (int A = 1; A <= n; A++) { sort(col+1, col+m+1, comp); for (int i = 1, cnt = 0; i <= m && cnt < (m+2)/2; i++) { cnt++; col[i].qtd--; if (col[i].qtd+1 >= (n+2)/2 && col[i].qtd < (n+2)/2) tot--; } if (A+tot > mx) { mx = A+tot; opt = A; } } for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) tab[i][j] = '-'; for (int i = 1; i <= m; i++) col[i] = {i, n}; for (int A = 1; A <= opt; A++) { sort(col+1, col+m+1, comp); for (int i = 1, cnt = 0; i <= m && cnt < (m+2)/2; i++) { cnt++; col[i].qtd--; tab[A][col[i].ind] = '+'; } } printf("%d\n", mx); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) printf("%c", tab[i][j]); printf("\n"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 4 3: 4 < 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 376 KB | Wrong answer in test 4 3: 4 < 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 4 3: 4 < 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 78 ms | 1528 KB | Wrong answer in test 97 21: 112 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 1532 KB | Output is correct |
2 | Correct | 70 ms | 1912 KB | Output is correct |
3 | Correct | 68 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 4 3: 4 < 5 |