Submission #167676

#TimeUsernameProblemLanguageResultExecution timeMemory
167676beso123Red-blue table (IZhO19_stones)C++14
15 / 100
134 ms5240 KiB
#include<bits/stdc++.h> #define int long long using namespace std; int t; bool sort21(pair<int,int> a,pair<int,int> b){ return a.first<b.first; } main(){ cin>>t; while(t--){ int n,m; cin>>n>>m; int M=(n/2)+1; int N=(m/2)+1; int a[n+1][m+1]; int b[max(n,m)+1]; for(int k=1;k<=n;k++){ b[k]=0; for(int i=1;i<=m;i++) a[k][i]=0; } if(n>=m){ int ans=n; for(int i=1;i<=m;i++){ vector<pair<int,int> > v; for(int k=1;k<=n;k++){ v.push_back({b[k],k}); } sort(v.begin(),v.end(),sort21); if(m-v[N-1].first==N) break; ans++; for(int k=0;k<N;k++){ a[v[k].second][i]=1; b[v[k].second]++; } } cout<<ans<<endl; for(int k=1;k<=n;k++){ for(int i=1;i<=m;i++) if(a[k][i]) cout<<'-'; else cout<<'+'; cout<<endl; } } else{ int ans=m; for(int i=1;i<=n;i++){ vector<pair<int,int> > v; for(int k=1;k<=m;k++){ v.push_back({b[k],k}); } sort(v.begin(),v.end(),sort21); if(n-v[M-1].first==M) break; ans++; for(int k=0;k<M;k++){ a[i][v[k].second]=1; b[v[k].second]++; } } cout<<ans<<endl; for(int k=1;k<=n;k++){ for(int i=1;i<=m;i++) if(a[k][i]) cout<<'+'; else cout<<'-'; cout<<endl; } } } return 0; }

Compilation message (stderr)

stones.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
stones.cpp: In function 'int main()':
stones.cpp:31:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(m-v[N-1].first==N)
         ^~
stones.cpp:33:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ans++;
             ^~~
stones.cpp:57:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
         if(n-v[M-1].first==M)
         ^~
stones.cpp:59:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
             ans++;
             ^~~
#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...