Submission #308757

#TimeUsernameProblemLanguageResultExecution timeMemory
308757nikatamlianiRed-blue table (IZhO19_stones)C++14
0 / 100
2083 ms40292 KiB
#include <bits/stdc++.h> using namespace std; int main() { int T = 1; cin >> T; while(T--) { int n, m, cntI = 0, best = 0; cin >> n >> m; char ans[n + 1][m + 1]; memset(ans, 0, sizeof ans); for(int i = 0; i <= n; ++i) { int sum = i * ((m + 1) / 2); int cnt_less = m - sum % m; int cnt_more = sum % m; int less = sum / n; int more = less + 1; int rem = n * m - sum, now = i; while(true) { bool done = false; if(cnt_less > 0 && rem >= less) { rem -= less; --cnt_less; done = true; } else { if(cnt_more > 0 && rem >= more) { rem -= more; --cnt_more; done = true; } } if(!done) break; ++now; } if(best < now) { best = now, cntI = i; } } int prev = 1; for(int i = 1; i <= cntI; ++i) { int cnt = (m + 1) / 2; for(int j = prev; cnt--; j = (j == m ? 1 : j + 1)) { prev = j + 1; ans[i][j] = '+'; } } for(int i = 1; i <= n; ++i) { for(int j = 1; j <= m; ++j) { if(ans[i][j] != '+') { cout << '-'; } else { cout << '+'; } } cout << '\n'; } } }
#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...