# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
146161 | 2019-08-22T11:51:00 Z | imeimi2000 | Red-blue table (IZhO19_stones) | C++17 | 15 ms | 2296 KB |
#include <iostream> #include <algorithm> #include <vector> using namespace std; char ans[1001][1002]; void solve() { int n, m; cin >> n >> m; int aA = 0, aB = 0; if (n < m) aB = m; else aA = n; for (int A = 0; A <= n; ++A) { for (int B = 0; B <= m; ++B) { if (A + B <= aA + aB) continue; if ((n - 1 >> 1) < (A * max(B - (m - 1 >> 1), 0) + B - 1) / B) continue; aA = A; aB = B; } } printf("%d\n", aA + aB); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (j > aB) ans[i][j] = '+'; else ans[i][j] = '-'; } ans[i][m + 1] = 0; } const int C = max(aB - (m - 1 >> 1), 0); for (int i = 1, j = 1; i <= aA; ++i) { for (int k = 0; k < C; ++k) { ans[i][j] = '+'; j = j % aB + 1; } } for (int i = 1; i <= n; ++i) printf("%s\n", ans[i] + 1); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while (T--) solve(); return 0; }
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 | 376 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 | 376 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1500 KB | Output is correct |
2 | Correct | 13 ms | 2040 KB | Output is correct |
3 | Correct | 12 ms | 2168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1528 KB | Output is correct |
2 | Correct | 11 ms | 1912 KB | Output is correct |
3 | Correct | 11 ms | 1656 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 | 376 KB | Output is correct |
4 | Correct | 3 ms | 504 KB | Output is correct |
5 | Correct | 15 ms | 1500 KB | Output is correct |
6 | Correct | 13 ms | 2040 KB | Output is correct |
7 | Correct | 12 ms | 2168 KB | Output is correct |
8 | Correct | 11 ms | 1528 KB | Output is correct |
9 | Correct | 11 ms | 1912 KB | Output is correct |
10 | Correct | 11 ms | 1656 KB | Output is correct |
11 | Correct | 6 ms | 632 KB | Output is correct |
12 | Correct | 11 ms | 1956 KB | Output is correct |
13 | Correct | 12 ms | 2040 KB | Output is correct |
14 | Correct | 9 ms | 1784 KB | Output is correct |
15 | Correct | 13 ms | 2296 KB | Output is correct |
16 | Correct | 10 ms | 1912 KB | Output is correct |
17 | Correct | 6 ms | 1400 KB | Output is correct |