Submission #919531

#TimeUsernameProblemLanguageResultExecution timeMemory
919531AnarTzRed-blue table (IZhO19_stones)C++17
0 / 100
45 ms2388 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cstring> using namespace std; int main() { long long t; cin >> t; while (t--) { int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus; ans = 0; cin >> n >> m; char table[n][m]; bool bosoo; if (n>m) { maxl = n; addl = (m-(m/2+1))*n/(n-n/2+1); bosoo = true; memset(table,'+',sizeof table); needed = n/2+1; }else{ maxl = m; addl = (n-(n/2+1))*m/(m-m/2+1); bosoo = false; memset(table,'-',sizeof table); needed = m/2+1; } ans = maxl + addl; cout << ans<<endl; check = needed*addl; q=0; w=0; while (check>0 && bosoo == false) { table[q][w]='+'; w++; check--; plus++; if (plus==maxl/2+1) { q++; plus=0; } if (w==maxl) { w=0; } } while (check>0 && bosoo == true) { table[w][q]='-'; w++; check--; plus++; if (plus==maxl/2+1) { q++; plus=0; } if (w==maxl) { w=0; } } for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { cout << table[i][j] << ' '; } cout << '\n'; } } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:11:21: warning: unused variable 'i' [-Wunused-variable]
   11 |         int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus;
      |                     ^
stones.cpp:11:23: warning: unused variable 'j' [-Wunused-variable]
   11 |         int ans,n,m,i,j,maxl,addl,needed,check,q,w,plus;
      |                       ^
stones.cpp:62:17: warning: 'plus' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |             plus++;
      |             ~~~~^~
#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...