Submission #898059

#TimeUsernameProblemLanguageResultExecution timeMemory
898059vjudge1Red-blue table (IZhO19_stones)C++17
38 / 100
212 ms13792 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6, X = 14; mt19937 rng(time(nullptr)); int t, n, m, ans, idx, r[N], c[N]; vector<string> a[X]; int f(int x) { for (int i = 0; i < n; i++) { r[i] = 0; } for (int i = 0; i < m; i++) { c[i] = 0; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (a[x][i][j] == '+') r[i]++; else c[j]++; } } int y = 0; for (int i = 0; i < n; i++) { y += (r[i] > m/2); } for (int i = 0; i < m; i++) { y += (c[i] > n/2); } return y; } /* void debug(int x) { cout << f(x) << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << a[x][i][j]; } cout << "\n"; } cout << "\n"; } */ signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> t; while (t--) { cin >> n >> m; ans = 0; // mis 4 construcciones a[0].clear(); a[0].resize(n, string(m, '-')); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (j <= m/2) a[0][i][j] = '+'; } } int y = f(0); if (y > ans) { ans = y; idx = 0; } // --- a[1].clear(); a[1].resize(n, string(m, '+')); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i <= n/2) a[1][i][j] = '-'; } } y = f(1); if (y > ans) { ans = y; idx = 1; } // --- a[2].clear(); a[2].resize(n, string(m, '+')); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if ((i <= n/2 && j < m/2) || (i >= n/2 && j > m/2)) a[2][i][j] = '-'; } } y = f(2); if (y > ans) { ans = y; idx = 2; } // --- a[3].clear(); a[3].resize(n, string(m, '-')); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if ((i < n/2 && j <= m/2) || (i > n/2 && j >= m/2)) a[3][i][j] = '+'; } } y = f(3); if (y > ans) { ans = y; idx = 3; } // X construcciones random for (int x = 0; x+4 < X; x++) { a[x+4].clear(); a[x+4].resize(n, string(m, '+')); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (rng() % 2) a[x+4][i][j] = '-'; } } int y = f(x+4); if (y > ans) { ans = y; idx = x+4; } } cout << ans << "\n"; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << a[idx][i][j]; } cout << "\n"; } } }
#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...