Submission #218331

#TimeUsernameProblemLanguageResultExecution timeMemory
218331LawlietRed-blue table (IZhO19_stones)C++17
100 / 100
52 ms2296 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1010; int n, m; int freq[MAXN]; char ans[MAXN][MAXN]; char aux[MAXN][MAXN]; int main() { int t; scanf("%d",&t); for(int k = 0 ; k < t ; k++) { scanf("%d %d",&n,&m); int qtdColumn = m; int optQtdLine = 0; int optQtdColumn = m; int A = m/2 + 1 - m; int B = (n - 1)/2; for(int qtdLines = 0 ; qtdLines <= n ; qtdLines++) { while( qtdLines*( A + qtdColumn ) > qtdColumn*B ) qtdColumn--; if( optQtdLine + optQtdColumn < qtdLines + qtdColumn ) { optQtdLine = qtdLines; optQtdColumn = qtdColumn; } } printf("%d\n",optQtdLine + optQtdColumn); for(int i = 1 ; i <= optQtdLine ; i++) freq[i] = m/2 + 1; int curCnt = 0; int curLine = 1; int curColumn = 1; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) ans[i][j] = 'x'; while( curColumn <= optQtdColumn && optQtdLine > 0 ) { if( freq[curLine] == 0 ) break; ans[curLine][curColumn] = '+'; curCnt++; freq[ curLine++ ]--; if( curCnt == n - n/2 - 1 ) { curCnt = 0; curColumn++; } if( curLine == optQtdLine + 1 ) curLine = 1; } for(int i = 1 ; i <= optQtdLine ; i++) for(int j = optQtdColumn + 1 ; j <= m ; j++) ans[i][j] = '+'; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) if( ans[i][j] == 'x' ) ans[i][j] = '-'; for(int i = 1 ; i <= n ; i++, printf("\n")) for(int j = 1 ; j <= m ; j++) printf("%c",ans[i][j]); } }

Compilation message (stderr)

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