Submission #331633

#TimeUsernameProblemLanguageResultExecution timeMemory
331633EnkhmunkhRed-blue table (IZhO19_stones)C++14
0 / 100
57 ms1388 KiB
#include <bits/stdc++.h> using namespace std; int n, m; void sol() { cin >> n >> m; if (m == 2) { // if (n < m) { cout << n << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << "+"; } cout << "\n"; } // } }else { char arr[n][m]; int tooll[m] = {0}; int hed = 0; if (n % 2 == 0) hed = n/2-1; else hed = n/2; int mm = m/2+1; int niit = m; for (int i = 0; i < n; i++) { bool k = false; if (i % 2 == 0) { //zuun for (int j = 0, mmm = mm; j < m; j++) { if (mmm > 0 && tooll[j] < hed) { arr[i][j] = '+'; tooll[j]++; mmm--; }else { if (mmm == 0 && k == false) { k = true; } arr[i][j] = '-'; } } }else { //baruun for (int j = m-1, mmm = mm; j >= 0; j--) { if (mmm > 0 && tooll[j] < hed) { arr[i][j] = '+'; mmm--; tooll[j]++; }else { if (mmm == 0 && k == false) { k = true; } arr[i][j] = '-'; } } } if (k) niit++; } cout << niit << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << arr[i][j]; } cout << "\n"; } cout << "\n"; } } int main () { int t; cin >> t; while (t--) sol(); } // + + + + + + - - - - // - - - - + + + + + + // + + + + - - + + - - // - - - - - - - - + + // - - - - - - - - - -
#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...