# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
599024 | 2022-07-19T09:15:21 Z | Plurm | Red-blue table (IZhO19_stones) | C++11 | 7 ms | 2772 KB |
#include <bits/stdc++.h> using namespace std; char table[1024][1024]; void build(int n, int m) { // n >= m for sure for (int i = 0; i < n / 2; i++) { for (int j = 0; j < m - 1; j++) { table[i][j] = j < (m - 1) / 2 ? '-' : '+'; } table[i][m - 1] = '+'; table[i][m] = '\0'; } for (int i = n / 2; i < n - 1; i++) { for (int j = 0; j < m - 1; j++) { table[i][j] = j < (m - 1) / 2 ? '+' : '-'; } table[i][m - 1] = '+'; table[i][m] = '\0'; } for (int j = 0; j < m - 1; j++) table[n - 1][j] = '-'; table[n - 1][m - 1] = '+'; table[n - 1][m] = '\0'; } char tmp[1024][1024]; void transpose(int n, int m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { tmp[j][i] = '+' ^ '-' ^ table[i][j]; } } for (int j = 0; j < m; j++) tmp[j][n] = '\0'; for (int i = 0; i < m; i++) { strcpy(table[i], tmp[i]); } } int count(int n, int m) { int cc = 0; for (int i = 0; i < n; i++) { int uc = 0; for (int j = 0; j < m; j++) { if (table[i][j] == '+') uc++; } if (uc > m - uc) cc++; } for (int j = 0; j < m; j++) { int uc = 0; for (int i = 0; i < n; i++) { if (table[i][j] == '-') uc++; } if (uc > n - uc) cc++; } return cc; } int main() { int t; scanf("%d", &t); while (t--) { int n, m; scanf("%d%d", &n, &m); if (n < m) { build(m, n); transpose(m, n); } else { build(n, m); } printf("%d\n", count(n, m)); for (int i = 0; i < n; i++) { printf("%s\n", table[i]); } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Wrong answer in test 2 4: 2 < 4 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 340 KB | Wrong answer in test 20 2: 10 < 20 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Wrong answer in test 2 4: 2 < 4 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1492 KB | Output is correct |
2 | Correct | 7 ms | 2772 KB | Output is correct |
3 | Correct | 5 ms | 2132 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1492 KB | Wrong answer in test 24 24: 23 < 44 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Wrong answer in test 2 4: 2 < 4 |
3 | Halted | 0 ms | 0 KB | - |