Submission #172651

#TimeUsernameProblemLanguageResultExecution timeMemory
172651LinusTorvaldsFanRed-blue table (IZhO19_stones)C++14
27 / 100
47 ms1620 KiB
#include <bits/stdc++.h> using namespace std; char f[2000][2000]; int ver[2000]; int hor[2000]; int main() { int t; cin>>t; for(;t;t--){ int n,m; cin>>n>>m; int ans=max(n,m); if(n>m){ for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ f[i][j]='+'; hor[i]=m; } } for(int j=0;j<m;j++){ int t=0; for(int i=0;i<n;i++){ if(t>=n/2+1)break; if(hor[i]-1>=m/2+1){ f[i][j]='-'; hor[i]--; t++; } } if(t==n/2+1)ans++; } } else{ for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ f[i][j]='-'; ver[j]=n; } } for(int i=0;i<n;i++){ int t=0; for(int j=0;j<m;j++){ if(t>=m/2+1)break; if(ver[j]-1>=n/2+1){ f[i][j]='+'; ver[j]--; t++; } } if(t==m/2+1)ans++; } } cout<<ans<<endl; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cout<<f[i][j]; } cout<<"\n"; } } 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...