Submission #711171

#TimeUsernameProblemLanguageResultExecution timeMemory
711171onlk97Red-blue table (IZhO19_stones)C++14
100 / 100
31 ms2232 KiB
#include <bits/stdc++.h> using namespace std; void solve(){ int n,m; cin>>n>>m; int ans1=-1,rr; for (int r=0; r<=n; r++){ int cnt=r,req=n/2+1-(n-r); if (req<=0) cnt+=m; else { int L=0,R=m; while (L<R){ int mid=(L+R+1)/2; if (r*min(mid,m-m/2-1)>=mid*req) L=mid; else R=mid-1; } cnt+=L; } if (cnt>ans1){ ans1=cnt; rr=r; } } cout<<ans1<<'\n'; int tt=ans1-rr; char op[n+1][m+1]; for (int i=1; i<=n; i++){ for (int j=1; j<=m; j++) op[i][j]=(i<=rr?'+':'-'); } if (n-rr<n/2+1){ int ut=min(ans1-rr,m-m/2-1); for (int j=1; j<=rr; j++){ for (int k=(j-1)*ut; k<j*ut; k++) op[j][k%(ans1-rr)+1]='-'; } } for (int i=1; i<=n; i++){ for (int j=1; j<=m; j++) cout<<op[i][j]; cout<<'\n'; } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while (t--) solve(); }

Compilation message (stderr)

stones.cpp: In function 'void solve()':
stones.cpp:25:9: warning: unused variable 'tt' [-Wunused-variable]
   25 |     int tt=ans1-rr;
      |         ^~
stones.cpp:6:17: warning: 'rr' may be used uninitialized in this function [-Wmaybe-uninitialized]
    6 |     int ans1=-1,rr;
      |                 ^~
#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...