# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
670019 | 2022-12-07T18:59:22 Z | YENGOYAN | Red-blue table (IZhO19_stones) | C++17 | 66 ms | 1296 KB |
#define _USE_MATH_DEFINES #include <climits> #include <bitset> #include <deque> #include <queue> #include <stack> #include <map> #include<iostream> #include<vector> #include<cmath> #include<iomanip> #include<algorithm> #include<set> #include<string> using namespace std; void anotherSol(int n, int m) { if (n + (m + 1) / 2 - 1 > m + (n + 1) / 2 - 1) { cout << n + (m + 1) / 2 - 1 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (j <= m / 2 + 1) cout << '+'; else cout << '-'; } cout << "\n"; } } else { cout << m + (n + 1) / 2 - 1 << endl; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (i <= n / 2 + 1) cout << '-'; else cout << '+'; } cout << "\n"; } } } void solve() { int n, m; cin >> n >> m; int mn = m + n; if (n % 2 == m % 2) { if (n % 2 == 0) { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 4) anotherSol(n, m); else { cout << n + m - 4 << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 2; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } } else { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 2) anotherSol(n, m); else { cout << n + m - 2 << endl; for (int i = 0; i < m; i++) cout << '-'; cout << endl; for (int i = 1; i < n; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } cout << endl; } } } } else { if (max(n + (m + 1) / 2 - 1, m + (n + 1) / 2 - 1) > n + m - 3) anotherSol(n, m); else { cout << n + m - 3 << endl; for (int i = 0; i < n - n % 2; i++) { if (i % 2) { for (int j = 0; j < m / 2 + 1; j++) cout << '+'; for (int j = m / 2 + 1; j < m; j++) cout << '-'; } else { for (int j = m / 2 + 1; j < m; j++) cout << '-'; for (int j = 0; j < m / 2 + 1; j++) cout << '+'; } if (m % 2) cout << '-'; cout << endl; } if (n % 2) { for (int i = 0; i < m; i++) cout << '+'; cout << endl; } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int t; cin >> t; while (t--) solve(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Incorrect | 8 ms | 340 KB | Wrong answer |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 66 ms | 1264 KB | Output is correct |
2 | Correct | 22 ms | 1120 KB | Output is correct |
3 | Correct | 20 ms | 1084 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 37 ms | 1296 KB | Wrong answer in test 6 6: 8 < 9 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Incorrect | 8 ms | 340 KB | Wrong answer |
5 | Halted | 0 ms | 0 KB | - |