Submission #525314

#TimeUsernameProblemLanguageResultExecution timeMemory
525314MagiRed-blue table (IZhO19_stones)C++14
100 / 100
28 ms2392 KiB
#include <iostream> #define NMAX 1000 using namespace std; char a[NMAX+10][NMAX+10]; void solve(){ int n, m; cin >> n >> m; int badColumns = 0; int ans = max(n, m), p = 0; if(n > m) p = n; for(int i=1; i<=n; i++){ int cnt = (m / 2 + 1) * i; if(cnt > (m - badColumns) * (((n + 1) / 2) - 1) + badColumns * i){ if(badColumns == m) break; i--; badColumns++; continue; } if(i + (m - badColumns) > ans){ ans = i + (m - badColumns); p = i; } } badColumns = 0; while(1){ int cnt = (m / 2 + 1) * p; if(cnt > (m - badColumns) * (((n + 1) / 2) - 1) + badColumns * p){ badColumns++; continue; } for(int j=1; j<=m; j++) for(int i=1; i<=n; i++){ if(j <= badColumns) a[i][j] = '+'; else a[i][j] = '-'; } int j = badColumns + 1; for(int i=1; i<=p; i++) for(int nr=1; nr<=m/2+1-badColumns; nr++){ a[i][j] = '+'; j++; if(j == m + 1) j = badColumns + 1; } cout << ans << '\n'; for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++) cout << a[i][j]; cout << '\n'; } break; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); 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...