Submission #992738

#TimeUsernameProblemLanguageResultExecution timeMemory
992738danikoynovRed-blue table (IZhO19_stones)C++14
100 / 100
24 ms2380 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } const int maxn = 1e3 + 10; int n, m; int d[maxn]; bool check(int r, int c, int t) { int con = min((m - 1) / 2, c); int nec = t * c; ///cout << r * con << " : " << nec << endl; return r * con >= nec; } char table[maxn][maxn]; void solve() { cin >> n >> m; //cout << check(3, 6, 1) << endl; //exit(0); int max_res = 0, mrow = -1, mcol = -1; for (int x = 0; x <= n; x ++) { int nec = n / 2 + 1 - (n - x); nec = max(nec, 0); int lf = 0, rf = m + 1; while(lf + 1 < rf) { int mf = (lf + rf) / 2; if (check(x, mf, nec)) lf = mf; else rf = mf; } if (x + lf > max_res) { max_res = x + lf; mrow = x; mcol = lf; } } cout << max_res << endl; ///cout << mrow << " " << mcol << endl; for (int i = 1; i <= n; i ++) for (int j = 1; j <= m; j ++) table[i][j] = '+'; for (int i = mrow + 1; i <= n; i ++) for (int j = 1; j <= mcol; j ++) table[i][j] = '-'; int pv = 1; int con = min((m - 1) / 2, mcol); for (int i = 1; i <= mrow; i ++) { for (int step = 1; step <= con; step ++) { if (pv > mcol) pv = 1; table[i][pv] = '-'; pv ++; } } for (int i = 1; i <= n; i ++, cout << endl) for (int j = 1; j <= m; j ++) cout << table[i][j]; } int main() { ///speed(); int t; cin >> t; while(t --) solve(); 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...