Submission #882277

#TimeUsernameProblemLanguageResultExecution timeMemory
882277preskoRed-blue table (IZhO19_stones)C++14
15 / 100
26 ms1912 KiB
#include<iostream> #include<bits/stdc++.h> using namespace std; char tab[1010][1010]; int main() { int t,n,m; ios_base::sync_with_stdio(false); cin.tie(0); cin>>t; for(int q=0;q<t;q++) { cin>>n>>m; int res1=n>>1,res2=m>>1; if(!(n&1))res1--; if(!(m&1))res2--; if(0)//build more rows { cout<<n+res2<<"\n"; string row=""; for(int i=0;i<m-res2;i++)row+="+"; for(int i=m-res2;i<m;i++)row+="-"; for(int i=0;i<n;i++)cout<<row<<"\n"; } else //build more columns { int ans=0; int used=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { int l1=m-res2*(i+1); if(l1<0){l1=abs(l1);l1%=m;l1=m-l1;} int l2=l1+res2; l2%=m; if(used<=res1) { if(l2-l1==res2) { if(j<l1 || j>=l2) { if(j==0)used++; if(used<=res1)tab[i][j]='+'; else tab[i][j]='-'; } else tab[i][j]='-'; } else { if(j<l1 && j>=l2) { if(j==0)used++; if(used<=res1)tab[i][j]='+'; else tab[i][j]='-'; } else tab[i][j]='-'; } } else tab[i][j]='-'; } if(used<=res1)ans++; } cout<<m+ans<<"\n"; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cout<<tab[i][j]; } cout<<"\n"; } /*cout<<m+res1<<"\n"; string row1="",row2=""; for(int i=0;i<m;i++){row1+="-";row2+="+";} for(int i=0;i<n-res1;i++)cout<<row1<<"\n"; for(int i=n-res1;i<n;i++)cout<<row2<<"\n";*/ } } }
#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...