# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344411 | 2021-01-05T17:29:48 Z | Sprdalo | Red-blue table (IZhO19_stones) | C++17 | 38 ms | 6928 KB |
#include <bits/stdc++.h> using namespace std; #define int ll typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<double> vd; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<string> vs; typedef vector<pi> vp; typedef vector<pl> vpl; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cerr.tie(nullptr); int t; cin >> t; for (int e = 0; e < t; ++e){ int n, m; cin >> n >> m; if (n <= 2){ cout << m << '\n'; for (int i = 0; i < n; ++i){ for (int j = 0; j < m; ++j) cout << "-"; cout << '\n'; } continue; } if (m <= 2){ cout << n << '\n'; for (int i = 0; i < n; ++i){ for (int j = 0; j < m; ++j) cout << "+"; cout << '\n'; } continue; } int l,r; if (n%2){ l = r = n/2; } else { l = n/2-1; r = n/2; } vector<vi> a(n, vi(m, -1)); for (int j = 0; j < m; ++j){ a[l][j] = a[r][j] = 0; } if (m%2) l = r = m/2; else{ l = m/2-1; r = m/2; } for (int i = 0; i < n; ++i){ a[i][l] = a[i][r] = 1; } for (int i = 0; i < n/2; ++i){ for (int j = 0; j < m/2; ++j){ if (a[i][j] != -1) continue; a[i][j] = 1; } } for (int i = 0; i < n/2; ++i){ for (int j = m/2; j < m; ++j){ if (a[i][j] != -1) continue; a[i][j] = 0; } } for (int i = n/2; i < n; ++i){ for (int j = 0; j < m/2; ++j){ if (a[i][j] != -1) continue; a[i][j] = 0; } } for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) if (a[i][j] == -1) a[i][j] = 1; int sol = 0; for (int i = 0; i < n; ++i){ int x = 0; for (int j = 0; j < m; ++j){ x += a[i][j]; } if (x > m/2){ ++sol; } } for (int j = 0; j < m; ++j){ int x = 0; for (int i = 0; i < n; ++i){ x += 1 - a[i][j]; } if (x > n/2) ++sol; } cout << sol << '\n'; for (int i = 0; i < n; ++i){ for (int j = 0; j < m; ++j) if (a[i][j]) cout << "+"; else cout << "-"; cout << '\n'; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 2 1: 1 < 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 1644 KB | Output is correct |
2 | Correct | 36 ms | 6252 KB | Output is correct |
3 | Correct | 34 ms | 6928 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 36 ms | 1748 KB | Wrong answer in test 4 4: 4 < 5 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Wrong answer in test 2 1: 1 < 2 |