# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
990476 | 2024-05-30T13:37:30 Z | ToniB | Red-blue table (IZhO19_stones) | C++17 | 43 ms | 1884 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int N = 1001; int t, n, m; bool ans[N][N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> t; while (t--) { cin >> n >> m; bool swp = 0; if (n > m) { swap(n, m); swp = 1; } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) ans[i][j] = 0; } int sum = m, mx = (n - 1) / 2; multiset<pii> ms; queue<pii> tmp; for (int i = 0; i < m; ++i) ms.insert({0, i}); for (int i = 0; i < n; ++i) { vector<int> cols; bool bad = 0; while (cols.size() < m / 2 + 1) { auto it = ms.begin(); int idx = (*it).second, cnt = (*it).first; ms.erase(it); if (cnt == mx) { bad = 1; break; } cols.push_back(idx); tmp.push({cnt + 1, idx}); } if (bad) break; for (int j : cols) ans[i][j] = 1; while (!tmp.empty()) { ms.insert(tmp.front()); tmp.pop(); } ++sum; } cout << sum << '\n'; if (swp) { for (int i = 0; i < m; ++i) { for (int j = 0; j < n; ++j) { if (ans[i][j]) cout << '-'; else cout << '+'; } cout << '\n'; } } else { for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { if (ans[i][j]) cout << '+'; else cout << '-'; } cout << '\n'; } } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | in the table A+B is not equal to 5 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 344 KB | in the table A+B is not equal to 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | in the table A+B is not equal to 5 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 43 ms | 1368 KB | in the table A+B is not equal to 116 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 42 ms | 1364 KB | Output is correct |
2 | Correct | 42 ms | 1884 KB | Output is correct |
3 | Correct | 39 ms | 1592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | in the table A+B is not equal to 5 |
3 | Halted | 0 ms | 0 KB | - |