Submission #1294944

#TimeUsernameProblemLanguageResultExecution timeMemory
1294944kawhietRed-blue table (IZhO19_stones)C++20
10 / 100
8 ms4408 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; bool rev = 0; if (n > m) { rev = 1; swap(n, m); } int t = (n + 1) / 2; vector<string> a(n, string(m, '+')); if (n == 3 && m % 2 == 0) { fill(a[0].begin(), a[0].end(), '-'); for (int i = 0; i <= m / 2; i++) { a[0][i] = '+'; } fill(a[1].begin(), a[1].end(), '-'); fill(a[2].begin(), a[2].end(), '-'); } else { for (int i = t; i < n; i++) { fill(a[i].begin(), a[i].end(), '-'); } int k = 0; for (int i = 0; i < (n + 1) / 2; i++) { fill(a[i].begin(), a[i].end(), '+'); for (int j = k; j < m; j += t) { a[i][j] = '-'; } k++; } } int cnt = 0; for (int i = 0; i < n; i++) { int red = 0, blue = 0; for (int j = 0; j < m; j++) { if (a[i][j] == '+') { red++; } else { blue++; } } cnt += red > blue; } for (int j = 0; j < m; j++) { int red = 0, blue = 0; for (int i = 0; i < n; i++) { if (a[i][j] == '+') { red++; } else { blue++; } } cnt += blue > red; } cout << cnt << '\n'; if (rev) { for (int j = 0; j < m; j++) { for (int i = 0; i < n; i++) { cout << (a[i][j] == '+' ? '-' : '+'); } cout << '\n'; } } else { for (auto s : a) { cout << s << '\n'; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { solve(); } 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...