Submission #500592

#TimeUsernameProblemLanguageResultExecution timeMemory
500592kusmetliqRed-blue table (IZhO19_stones)C++14
27 / 100
54 ms1308 KiB
#include<bits/stdc++.h> using namespace std; void solve() { int n,m; cin>>n>>m; char ans1[n][m],ans2[n][m]; int a1=n,a2=m; vector<int>v1(n,0),v2(m,0); for(int j=0;j<m;j++) { int cnt=0; for(int i=0;i<n;i++) { if(v1[i]<(m+1)/2-1)cnt++; } if(cnt>n/2) { a1++; int num=n/2+1; for(int i=0;i<n;i++) { if(v1[i]<m/2 && num!=0) { v1[i]++; num--; ans1[i][j]='-'; } else ans1[i][j]='+'; } } else for(int i=0;i<n;i++)ans1[i][j]='+'; } for(int i=0;i<n;i++) { int cnt=0; for(int j=0;j<m;j++) { if(v2[j]<(n+1)/2-1)cnt++; } if(cnt>m/2) { a2++; int num=m/2+1; for(int j=0;j<m;j++) { if(v2[j]<n/2 && num!=0) { v2[j]++; num--; ans2[i][j]='+'; } else ans2[i][j]='-'; } } else for(int j=0;j<m;j++)ans2[i][j]='-'; } cout<<max(a1,a2)<<endl; if(a2>a1) for(int i=0;i<n;i++) { for(int j=0;j<m;j++) cout<<ans2[i][j]; cout<<endl; } else for(int i=0;i<n;i++) { for(int j=0;j<m;j++) cout<<ans1[i][j]; cout<<endl; } } int main() { 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...