# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202990 | 2020-02-18T22:20:14 Z | luciocf | Red-blue table (IZhO19_stones) | C++14 | 84 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) { col[i].qtd = 1e9; 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 | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 376 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | in the table A+B is not equal to 5 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 81 ms | 1400 KB | Wrong answer in test 97 21: 112 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 84 ms | 1528 KB | Output is correct |
2 | Correct | 71 ms | 1912 KB | Output is correct |
3 | Correct | 76 ms | 1784 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 | in the table A+B is not equal to 5 |