Submission #342285

#TimeUsernameProblemLanguageResultExecution timeMemory
342285_aniRed-blue table (IZhO19_stones)C++17
0 / 100
47 ms1516 KiB
#include <iostream> #include <algorithm> using namespace std; char s[1002][1002]; int main() { int t; cin >> t; while (t--) { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) s[i][j] = '+'; int A, B, ans; if (n > m) { A = n; B = 0; ans = n; } else { A = 0; B = m; ans = m; } for (int a = 1; a <= n; a++) { int k = (n + 1) / 2 - (n - a); if (k == 0) { if (a + m > ans) ans = a + m; A = a; B = m; continue; } int b = (m / 2) * a / k; while (k * b / a + ((k * b) % a ? 1 : 0) > m / 2) b--; if (a + b > ans) ans = a + b; A = a; B = b; } int i = 0, j = 0; int k = (n + 1) / 2 - (n - A); while (i < B) { int cnt = 0; while (cnt < k) { s[j][i] = '-'; j++; if (j >= A) j = 0; cnt++; } i++; } for (int i = 0; i < B; i++) for (int j = A; j < n; j++) s[j][i] = '-'; cout << ans << '\n'; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) cout << s[i][j]; cout << '\n'; } } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:28:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |     if (a + m > ans)
      |     ^~
stones.cpp:29:19: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   29 |      ans = a + m; A = a; B = m;
      |                   ^
stones.cpp:35:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   35 |    if (a + b > ans)
      |    ^~
stones.cpp:36:18: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   36 |     ans = a + b; A = a; B = b;
      |                  ^
#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...