Submission #503300

#TimeUsernameProblemLanguageResultExecution timeMemory
503300PetyRed-blue table (IZhO19_stones)C++14
100 / 100
32 ms2236 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; const ll MOD = 1e9 + 7; const ll INF = 1e9; const int N = 1e5 + 2; int t, n, m; char a[1002][1002]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { cin >> n >> m; int ans = 0, lin = 0, col = 0; for (int i = 0; i <= n; i++) for (int j =0; j <= m; j++) { if (m / 2 + 1 <= m - j || n / 2 + 1 <= n - i) { if (ans < i + j) { ans = i + j; lin = i; col = j; } } else { int l = m / 2 + 1 - (m - j); int c = n / 2 + 1 - (n - i); int nr = (j + l * i - 1) / j; if (c <= i - nr && ans < i + j) { ans = i + j; lin = i; col = j; } } } cout << ans << "\n"; for (int i = 0; i < lin; i++) for (int j = m - 1; j >= col; j--) a[i][j] = '+'; for (int j = 0; j < col; j++) for (int i = n - 1; i >= 0; i--) a[i][j] = '-'; if (m / 2 + 1 > m - col) { int c = m / 2 + 1 - (m - col); int k = 0; for (int i = 0; i < lin; i++) { for (int j = 0; j < c; j++) { a[i][k] = '+'; k = (k + 1) % col; } } } for (int i = lin; i < n; i++) for (int j = col; j < m; j++) a[i][j] = '-'; for (int i = 0; i < n; i++, cout << "\n") for (int j = 0; j < m; j++) cout << a[i][j]; } 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...