# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
345491 | 2021-01-07T13:27:04 Z | georgerapeanu | Red-blue table (IZhO19_stones) | C++11 | 53 ms | 9840 KB |
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int t; int n,m; int main(){ scanf("%d",&t); while(t--){ scanf("%d %d",&n,&m); bool sw = (n > m); if(sw){ swap(n,m); } vector<vector<int> > ans(n + 1,vector<int>(m + 1)); int cnt_available = max(0,(n - 1) / 2) - 1; int lst = 1; int ans_sum = m; for(int i = 1;i <= n && cnt_available >= 0;i++){ bool success = true; for(int j = 0;j < m / 2 + 1;j++){ lst++; if(lst > m){ lst = 1; cnt_available--; if(cnt_available < 0){ success = false; break; } } ans[i][lst] = 1; } ans_sum += success; } if(sw){ swap(n,m); vector<vector<int> > tmp(n + 1,vector<int>(m + 1)); for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ tmp[i][j] = ans[j][i] ^ 1; } } ans = tmp; } printf("%d\n",ans_sum); for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++){ printf(ans[i][j] == 0 ? "-":"+"); } printf("\n"); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 396 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 396 KB | Output is correct |
4 | Incorrect | 6 ms | 364 KB | Wrong answer in test 6 5: 8 < 9 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 1516 KB | Output is correct |
2 | Correct | 51 ms | 4096 KB | Output is correct |
3 | Correct | 48 ms | 9840 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 1516 KB | Wrong answer in test 6 6: 8 < 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 396 KB | Output is correct |
4 | Incorrect | 6 ms | 364 KB | Wrong answer in test 6 5: 8 < 9 |