Submission #1172533

#TimeUsernameProblemLanguageResultExecution timeMemory
1172533AtabayRajabliRed-blue table (IZhO19_stones)C++20
0 / 100
15 ms2120 KiB
#include <bits/stdc++.h> #define int long long #define all(v) v.begin(), v.end() using namespace std; const int sz = 1e3 + 1, inf = 1e18; int n, m, a[sz][sz], ans; void calc(int n, int m) { if(n >= m) swap(n, m); int mx = m / 2 + 1, nx = (n - 1) / 2, col[m + 1] = {0}, row[n + 1] = {0}; for(int i = 1; i <= n; ) { bool ok = 0; for(int j = 1; j <= m; j++) { if(col[j] == nx) continue; ok |= 1; a[i][j] = 1; col[j]++; row[i]++; if(row[i] == mx) i++; } if(!ok) break; } ans = 0; for(int i = 1; i <= n; i++) ans += (row[i] == mx); for(int i = 1; i <= m; i++) ans += (col[i] <= nx); } void solve() { cin >> n >> m; calc(n, m); cout << ans << '\n'; if(n >= m) { for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cout << (a[i][j] ? '+' : '-'); } cout << '\n'; } } else { for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cout << (a[j][i] ? '+' : '-'); } cout << '\n'; } } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while(t--) solve(); }
#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...