# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
202987 | 2020-02-18T21:47:41 Z | luciocf | Red-blue table (IZhO19_stones) | C++14 | 77 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++) { if (col[i].qtd != 0) { cnt++; col[i].qtd--; if (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++) { if (col[i].qtd != 0) { 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 | 248 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 376 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 248 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 77 ms | 1588 KB | Wrong answer in test 97 21: 112 < 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 75 ms | 1528 KB | Output is correct |
2 | Correct | 74 ms | 1912 KB | Output is correct |
3 | Correct | 65 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 248 KB | Output is correct |
2 | Incorrect | 5 ms | 376 KB | Wrong answer in test 2 1: 1 < 2 |