Submission #333995

#TimeUsernameProblemLanguageResultExecution timeMemory
333995boykutRed-blue table (IZhO19_stones)C++14
0 / 100
35 ms1352 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int n, m; cin >> n >> m; char a[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) a[i][j] = '+'; if (n == 1) { for (int j = 0; j < m; j++) { a[0][j] = '-'; } } else if (m == 1) { for (int i = 0; i < n; i++) { a[i][0] = '-'; } } else if (n == 2) { for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (j & 1) a[i][j] = '-'; } else if (m == 2) { for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (i & 1) a[i][j] = '-'; } else if (m & 1) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) if (j & 1) a[i][j] = '-'; } } else if (n & 1) { for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (i & 1) a[i][j] = '-'; } int A = 0, B = 0; for (int i = 0; i < n; i++) { int cnt = 0; for (int j = 0; j < m; j++) { if (a[i][j] == '+') cnt++; } if (cnt > m / 2) A++; } for (int j = 0; j < m; j++) { int cnt = 0; for (int i = 0; i < n; i++) { if (a[i][j] == '-') cnt++; } if (cnt > n / 2)B++; } cout << A + B << '\n'; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << a[i][j]; cout << '\n'; } } 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...