제출 #526601

#제출 시각아이디문제언어결과실행 시간메모리
526601Zhora_004Red-blue table (IZhO19_stones)C++17
27 / 100
66 ms336 KiB
#include <iostream> #include <vector> using namespace std; bool t1(int n, int m) { return max(n, m) <= 4; } bool t2(int n, int m) { return min(n, m) <= 3; } void test_case() { int n, m; cin >> n >> m; if (t1(n, m)) { int mx = 0; vector<vector<bool>> ans; int k = n * m; for (int i = 0; i < (1 << k); i++) { vector<vector<bool>> v(n, vector<bool>(m)); for (int j = 0; j < k; j++) { if ((i >> j) & 1) { int r = j / m, c = j % m; v[r][c] = 1; } } int A = 0, B = 0; for (int j = 0; j < n; j++) { int a = 0, b = 0; for (int k = 0; k < m; k++) { if (v[j][k]) a++; else b++; } if (a > b) A++; } for (int j = 0; j < m; j++) { int a = 0, b = 0; for (int k = 0; k < n; k++) { if (v[k][j]) a++; else b++; } if (b > a) B++; } if (A + B > mx) ans = v, mx = A + B; } cout << mx << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (ans[i][j]) cout << '+'; else cout << '-'; } cout << "\n"; } return; } if (t2(n, m)) { if (m >= n) { if (n <= 2) cout << m << "\n"; else cout << m + 1 << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i < (n - 1) / 2) cout << '+'; else cout << '-'; } cout << "\n"; } } else { if (m <= 2) cout << n << "\n"; else cout << n + 1 << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m - 1; j++) cout << '+'; if (m <= 2) cout << "+\n"; else cout << "-\n"; } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int tc; cin >> tc; while (tc--) test_case(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...