Submission #146468

#TimeUsernameProblemLanguageResultExecution timeMemory
146468achibasadzishviliRed-blue table (IZhO19_stones)C++14
100 / 100
82 ms2424 KiB
#include<bits/stdc++.h> #define ll int #define f first #define s second #define pb push_back using namespace std; ll n,m,ind,ned1,ned2,ans,indx,indy; char a[1005][1005]; int main(){ ios::sync_with_stdio(false); int t; cin >> t; while(t--){ cin >> n >> m; ned1 = (m + 2) / 2; ned2 = (n + 2) / 2; ans = 0; for(int i=0; i<=n; i++){ int l=0,r=m,mid; ind = 0; while(r >= l){ mid = (l + r) / 2; if(i * (mid - ned1 + (m - mid)) >= mid * (ned2 - (n - i))){ l = mid + 1; ind = mid; } else { r = mid - 1; } } if(i + ind > ans){ ans = i + ind; indx = i; indy = ind; } } cout << ans << endl;; for(int i=indx+1; i<=n; i++) for(int j=1; j<=m; j++) a[i][j] = '-'; for(int j=indy + 1; j<=m; j++) for(int i=1; i<=n; i++) a[i][j] = '+'; int k = indy - ned1 + (m - indy),p; if(k <= 0){ for(int i=1; i<=indx; i++) for(int j=1; j<=indy; j++) a[i][j] ='+'; } else { int l = 1; for(int i=1; i<=indx; i++) for(int j=1; j<=indy; j++) a[i][j] = '+'; for(int i=1; i<=indx; i++){ p = k; while(p--){ a[i][l] = '-'; l++; if(l == indy + 1) l = 1; } } } for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++) cout << a[i][j]; cout << endl; } } 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...