# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171034 | 2019-12-27T06:21:43 Z | antimirage | Red-blue table (IZhO19_stones) | C++14 | 49 ms | 5240 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 1005; int tests, n, m, a[N][N], cn[N], ans; void Fill (int x) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { a[i][j] = x; } } } int Nxt(int x, int o) { x++; if (x > o) x = 1; return x; } main() { cin >> tests; while (tests--) { memset(cn, 0, sizeof(cn) ); scanf("%d%d", &n, &m); int l = 1; if (n >= m) { ans = n; Fill(0); for (int i = 1; i <= m; i++) { bool ok = 0; for (int j = 0; j < n / 2 + 1; j++) { if (cn[l] + 1 >= (m + 1) / 2) { ok = 1; break; } a[l][i] = 1; cn[l]++; l = Nxt(l, n); } if (ok) break; ans++; } } else { ans = m; Fill(1); for (int i = 1; i <= n; i++) { bool ok = 0; for (int j = 0; j < m / 2 + 1; j++) { if (cn[l] + 1 >= (n + 1) / 2) { ok = 1; break; } a[i][l] = 0; cn[l]++; l = Nxt(l, m); } if (ok) break; ans++; } } printf("%d\n", ans); for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { printf(a[i][j] == 0 ? "+" : "-"); } printf("\n"); } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 1784 KB | Output is correct |
2 | Correct | 48 ms | 4216 KB | Output is correct |
3 | Correct | 41 ms | 4984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 1912 KB | Output is correct |
2 | Correct | 39 ms | 3964 KB | Output is correct |
3 | Correct | 35 ms | 3320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 3 ms | 504 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
5 | Correct | 43 ms | 1784 KB | Output is correct |
6 | Correct | 48 ms | 4216 KB | Output is correct |
7 | Correct | 41 ms | 4984 KB | Output is correct |
8 | Correct | 44 ms | 1912 KB | Output is correct |
9 | Correct | 39 ms | 3964 KB | Output is correct |
10 | Correct | 35 ms | 3320 KB | Output is correct |
11 | Correct | 12 ms | 760 KB | Output is correct |
12 | Correct | 37 ms | 4216 KB | Output is correct |
13 | Correct | 39 ms | 4728 KB | Output is correct |
14 | Correct | 29 ms | 4004 KB | Output is correct |
15 | Correct | 49 ms | 5240 KB | Output is correct |
16 | Correct | 33 ms | 4208 KB | Output is correct |
17 | Correct | 18 ms | 3320 KB | Output is correct |