# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
256102 | 2020-08-02T09:49:33 Z | karma | Red-blue table (IZhO19_stones) | C++14 | 44 ms | 2296 KB |
#include <bits/stdc++.h> #define pb emplace_back #define ll long long #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; const int N = int(1e3) + 7; const int inf = 1e9 + 1; typedef pair<ll, ll> pii; int n, m, nr, nc, r, c, res; void solve() { cin >> n >> m; res = m, r = 0, c = m; nr = m / 2 + 1, nc = n / 2 + 1; for(int l, h, mid, i = 1; i <= n; ++i) { l = 0, h = m; while(l <= h) { mid = l + h >> 1; int x = min(mid, m - nr); int tmp = x * (n - nc); if(nr - m + mid <= 0) l = mid + 1; else if(tmp / (nr - m + mid) + (n - nc) >= i) l = mid + 1; else h = mid - 1; } if(i + h > res) res = i + h, r = i, c = h; } cout << res << '\n'; vector<vector<char>> ans(n, vector<char>(m, '-')); int x = 0; for(int i = 0; i < r; ++i) { int tmp = nr; for(int j = m - 1; tmp > 0 && j >= c; --j, --tmp) ans[i][j] = '+'; while(tmp--) { ans[i][x] = '+'; x++; if(x >= c) x = 0; } } for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) cout << ans[i][j]; cout << '\n'; } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define Task "test" if(fopen(Task".inp", "r")) { freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout); } int T; cin >> T; while(T --) solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 44 ms | 1400 KB | Output is correct |
2 | Correct | 28 ms | 1664 KB | Output is correct |
3 | Correct | 24 ms | 1912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 1400 KB | Output is correct |
2 | Correct | 37 ms | 1536 KB | Output is correct |
3 | Correct | 22 ms | 1356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 4 ms | 384 KB | Output is correct |
5 | Correct | 44 ms | 1400 KB | Output is correct |
6 | Correct | 28 ms | 1664 KB | Output is correct |
7 | Correct | 24 ms | 1912 KB | Output is correct |
8 | Correct | 33 ms | 1400 KB | Output is correct |
9 | Correct | 37 ms | 1536 KB | Output is correct |
10 | Correct | 22 ms | 1356 KB | Output is correct |
11 | Correct | 11 ms | 640 KB | Output is correct |
12 | Correct | 22 ms | 1576 KB | Output is correct |
13 | Correct | 32 ms | 1352 KB | Output is correct |
14 | Correct | 18 ms | 1152 KB | Output is correct |
15 | Correct | 28 ms | 2296 KB | Output is correct |
16 | Correct | 21 ms | 1792 KB | Output is correct |
17 | Correct | 10 ms | 1024 KB | Output is correct |