Submission #223786

#TimeUsernameProblemLanguageResultExecution timeMemory
223786sochoRed-blue table (IZhO19_stones)C++14
27 / 100
82 ms1400 KiB
#include "bits/stdc++.h" using namespace std; // #define endl '\n' // #define double long double // #define int long long // int MOD = 1000 * 1000 * 1000 + 7; // int MOD = 998244353; void solve() { int n, m; cin >> n >> m; bool grid[n][m]; // 1 is +, 0 is - memset(grid, 1, sizeof grid); int best = n; int bX = n; int bA = m; for (int x=0; x<=n; x++) { int y = n - x; for (int a=0; a<=m; a++) { int b = m - a; int ans = 0; if (x > y) { ans += b; } else if (y > x) { ans += a; } if (a > b) { ans += x; } else if (b > a) { ans += y; } if (ans > best) { best = ans; bX = x; bA = a; } } } for (int i=0; i<bX; i++) { for (int j=bA; j<m; j++) { grid[i][j] = 0; } } for (int i=bX; i<n; i++) { for (int j=0; j<bA; j++) { grid[i][j] = 0; } } cout << best << endl; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { if (grid[i][j]) cout << '+'; else cout << '-'; } cout << endl; } } signed main() { int t; cin >> t; while (t--) solve(); }
#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...