Submission #161909

#TimeUsernameProblemLanguageResultExecution timeMemory
161909Alexa2001Red-blue table (IZhO19_stones)C++17
100 / 100
10 ms3448 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 1005; bool marked[Nmax][Nmax]; char ans[Nmax][Nmax]; int cnt[Nmax]; int my_ans; void prec(int n, int m) { int i, j; for(i=1; i<=n; ++i) for(j=1; j<=m; ++j) marked[i][j] = 0, cnt[j] = 0; int nc, mc; mc = m / 2 + 1; nc = (n-1)/2; int start = 1, step; my_ans = m; for(i=1; i<=n; ++i) { for(step = 1; step <= mc; ++step) { if(cnt[start] == nc) break; ++cnt[start]; marked[i][start] = 1; ++start; if(start == m+1) start = 1; } if(step == mc + 1) ++my_ans; } } void solve() { int n, m; cin >> n >> m; if(n > m) prec(m, n); else prec(n, m); int i, j; if(n <= m) { for(i=1; i<=n; ++i) for(j=1; j<=m; ++j) ans[i][j] = (marked[i][j] ? '+' : '-'); } else { for(i=1; i<=n; ++i) for(j=1; j<=m; ++j) ans[i][j] = (marked[j][i] ? '-' : '+'); } cout << my_ans << '\n'; for(i=1; i<=n; ++i) { ans[i][m+1] = 0; cout << (ans[i] + 1) << '\n'; } } int main() { // freopen("input", "r", stdin); cin.sync_with_stdio(false); cin.tie(0); int tests; cin >> tests; while(tests--) 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...