Submission #342289

#TimeUsernameProblemLanguageResultExecution timeMemory
342289_aniRed-blue table (IZhO19_stones)C++17
17 / 100
54 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 / 2 + 1) - (n - a); if (k == 0) { if (a + m > ans) { ans = a + m; A = a; B = m; } continue; } int b = ((m - 1) / 2) * a / k; while (k * b / a + ((k * b) % a ? 1 : 0) > (m - 1) / 2) b--; if (a + b > ans) { ans = a + b; A = a; B = b; } } int i = 0, j = 0; int k = (n / 2 + 1) - (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; }
#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...