Submission #1294886

#TimeUsernameProblemLanguageResultExecution timeMemory
1294886kawhietRed-blue table (IZhO19_stones)C++20
0 / 100
5 ms2364 KiB
#include <bits/stdc++.h> using namespace std; void solve() { int n, m; cin >> n >> m; int x = m + (n - 1) / 2; int y = n + (m - 1) / 2; vector<string> a(n, string(m, ' ')); if (x > y) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = (i % 2 == 0 ? '-' : '+'); } } } else { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = (j % 2 == 0 ? '+' : '-'); } } } 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; } assert(cnt == max(x, y)); for (auto s : a) { cout << x << '\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...