Submission #503257

#TimeUsernameProblemLanguageResultExecution timeMemory
503257MherRed-blue table (IZhO19_stones)C++14
0 / 100
53 ms1416 KiB
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <string> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <cmath> #include <bitset> #include <unordered_map> #include <stack> #include <random> using namespace std; const int N = 1003, M = 103; const int mod = 1e9 + 7; int n, m; int calc(int a, int b, int np) { return a - (np * a + b - 1) / b; } bool check(int a, int b) { if (a * b == 0) return true; int np = max(0, m / 2 + 1 - (m - b)); int nm = max(0, n / 2 + 1 - (n - a)); //cout << a << ' ' << b << endl << np << ' ' << nm << ' ' << calc(a, b, np) << endl; return nm <= calc(a, b, np); } bool ans[N][N]; void answ(int a, int b) { int np = max(0, m / 2 + 1 - (m - b)); int r = 0, l = 0; for (int i = 0; i < a * np; i++) { ans[r][l] = true; l++; l %= b; r += i % a == 0; } for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i >= a) cout << '-'; else if (j >= b) cout << '+'; else cout << (ans[i][j] ? '+' : '-'); } cout << endl; } } void solve() { cin >> n >> m; int as = 0, a = 0, b = 0; for (int i = n; i >= 0; i--) { for (int j = m; j >= 0; j--) { if (!check(i, j)) continue; if (i + j > as) { a = i; b = j; as = i + j; } } } cout << as << endl; answ(a, b); for (int i = 0; i < a; i++) { for (int j = 0; j < b; j++) ans[i][j] = false; } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(9); cout << fixed; int q = 1; cin >> q; while (q--) 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...