Submission #893270

#TimeUsernameProblemLanguageResultExecution timeMemory
893270maxFedorchukRed-blue table (IZhO19_stones)C++14
11 / 100
19 ms1884 KiB
#include <bits/stdc++.h> using namespace std; void fun() { long long n,m; cin>>n>>m; bool swp=0; if(m>n) { swap(n,m); swp=1; } char ch[n+5][m+5]; for(long long i=1;i<=n;i++) { for(long long j=1;j<=m;j++) { ch[i][j]='+'; } } long long mx_can_in_row=(m-1)/2; long long mn_ned_st=(n+1)/2; long long zarc=0,st=1; for(long long i=0;i<mx_can_in_row;i++) { for(long long j=1;(j<=n && st<=m);j++) { ch[j][st]='-'; zarc++; if(zarc>=mn_ned_st) { st++; zarc=0; } } } long long ans=n; for(long long j=1;j<=m;j++) { long long km=0; for(long long i=1;i<=n;i++) { km+=(ch[i][j]=='-'); } ans+=(km>=mn_ned_st); } cout<<ans<<"\n"; if(swp) { for(long long j=1;j<=m;j++) { for(long long i=1;i<=n;i++) { if(ch[i][j]=='+') { cout<<"-"; } else { cout<<"+"; } } cout<<"\n"; } } else { for(long long i=1;i<=n;i++) { for(long long j=1;j<=m;j++) { cout<<ch[i][j]; } cout<<"\n"; } } return; } int main() { cin.tie(0); ios_base::sync_with_stdio(0); long long t; cin>>t; while(t--) { fun(); } 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...