# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171205 | 2019-12-27T18:49:59 Z | donentseto | Red-blue table (IZhO19_stones) | C++14 | 30 ms | 1428 KB |
#include <bits/stdc++.h> using namespace std; int main (){ ios::sync_with_stdio (false); cin.tie (0); int t; cin >> t; while (t --){ int n, m; cin >> n >> m; if (n <= 2 && m >= n){ cout << m << '\n'; for (int i = 0; i < n; i ++){ for (int j = 0; j < m; j ++) cout << '-'; cout << '\n'; } } else if (m <= 2){ cout << n << '\n'; for (int i = 0; i < n; i ++){ for (int j = 0; j < m; j ++) cout << '+'; cout << '\n'; } } /*else if (n <= 4 && m >= n){ cout << m + 1 << '\n'; for (int i = 0; i < m; i ++) cout << '+'; cout << '\n'; for (int i = 1; i < n; i ++){ for (int i = 0; i < m; i ++) cout << '-'; cout << '\n'; } } else if (m <= 4){ cout << n + 1 << '\n'; for (int i = 0; i < n; i ++){ cout << '-'; for (int j = 1; j < m; j ++) cout << '+'; cout << '\n'; } }*/ else if (m % 2 == 0 && (n - 1 >> 1) << 1 <= (m >> 1) + 1){ cout << m + n - 3 + n % 2 << '\n'; for (int i = 0; i < n - 1 >> 1; i ++){ for (int j = 0; j <= m >> 1; j ++){ if (j >> 1 == i) cout << '+'; else cout << '-'; } for (int j = 1; j < m >> 1; j ++) cout << '+'; cout << '\n'; } for (int i = n & 1; i < 3; i ++){ for (int j = 0; j < m; j ++) cout << '-'; cout << '\n'; } for (int i = 1; i < n - 1 >> 1; i ++){ for (int j = 0; j <= m >> 1; j ++) cout << '+'; for (int j = 1; j < m >> 1; j ++) cout << '-'; cout << '\n'; } } else if (n % 2 == 0 && (m - 1 >> 1) << 1 <= (n >> 1) + 1){ cout << m + n - 3 + m % 2 << '\n'; for (int i = 0; i <= n >> 1; i ++){ for (int j = 0; j < m - 1 >> 1; j ++){ if (i >> 1 == j) cout << '-'; else cout << '+'; } for (int j = m & 1; j < 3; j ++) cout << '+'; for (int j = 1; j < m - 1 >> 1; j ++) cout << '-'; cout << '\n'; } for (int i = 1; i < n >> 1; i ++){ for (int j = 0; j < m - 1 >> 1; j ++) cout << '-'; for (int j = 0; j <= m >> 1; j ++) cout << '+'; cout << '\n'; } } else{ cout << n - 2 + n % 2 + m - 2 + m % 2 << '\n'; for (int i = 0; i < n; i ++){ for (int j = 0; j < m; j ++){ if (i <= n >> 1 && j < m - 1 >> 1) cout << '-'; else if (i >= n - 1 >> 1 && j > m >> 1) cout << '-'; else cout << '+'; } cout << '\n'; } } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 580 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 1428 KB | Output is correct |
2 | Correct | 28 ms | 1272 KB | Output is correct |
3 | Correct | 26 ms | 1272 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 1404 KB | Output is correct |
2 | Correct | 25 ms | 1144 KB | Output is correct |
3 | Correct | 23 ms | 1144 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 580 KB | Output is correct |
5 | Correct | 26 ms | 1428 KB | Output is correct |
6 | Correct | 28 ms | 1272 KB | Output is correct |
7 | Correct | 26 ms | 1272 KB | Output is correct |
8 | Correct | 30 ms | 1404 KB | Output is correct |
9 | Correct | 25 ms | 1144 KB | Output is correct |
10 | Correct | 23 ms | 1144 KB | Output is correct |
11 | Correct | 11 ms | 632 KB | Output is correct |
12 | Correct | 23 ms | 1144 KB | Output is correct |
13 | Correct | 26 ms | 1144 KB | Output is correct |
14 | Correct | 18 ms | 1008 KB | Output is correct |
15 | Correct | 29 ms | 1400 KB | Output is correct |
16 | Correct | 22 ms | 1064 KB | Output is correct |
17 | Correct | 12 ms | 760 KB | Output is correct |