Submission #201987

#TimeUsernameProblemLanguageResultExecution timeMemory
201987guangxuanRed-blue table (IZhO19_stones)C++14
100 / 100
13 ms2296 KiB
#include <bits/stdc++.h> using namespace std; char ans[1002][1002]; int main(){ int T; scanf("%d",&T); while(T--){ int n,m; scanf("%d%d",&n,&m); int ans1 = n + (m-1)/2, ans2 = m + (n-1)/2; for(int x=1;x<m;x++){ if((n*x + (m-1)/2 + x - 1)/((m-1)/2 + x) <= (n-1)/2)ans1++; else break; } for(int x=1;x<n;x++){ if((m*x + (n-1)/2 + x - 1)/((n-1)/2 + x) <= (m-1)/2)ans2++; else break; } printf("%d\n",max(ans1,ans2)); if(ans1>ans2){ int x = ans1 - (n+(m-1)/2); for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if(j<x+(m-1)/2)ans[i][j]='-'; else ans[i][j]='+'; } for (int j = i * x; j< (i+1) * x; j++){ ans[i][j%(x+(m-1)/2)] = '+'; } ans[i][m] = '\0'; } } else{ int x = ans2 - (m+(n-1)/2); for(int j=0;j<m;j++){ for(int i=0;i<n;i++){ if(i<x+(n-1)/2)ans[i][j]='+'; else ans[i][j]='-'; } for (int i = j * x; i< (j+1) * x; i++){ ans[i%(x+(n-1)/2)][j] = '-'; } } for(int i=0;i<n;i++)ans[i][m]='\0'; } for(int i=0;i<n;i++)printf("%s\n",ans[i]); } }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&T);
  ~~~~~^~~~~~~~~
stones.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&n,&m);
   ~~~~~^~~~~~~~~~~~~~
#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...