Submission #683753

#TimeUsernameProblemLanguageResultExecution timeMemory
683753gagik_2007Red-blue table (IZhO19_stones)C++17
100 / 100
43 ms2216 KiB
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <chrono> #include <ctime> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <limits> #include <iomanip> #include <unordered_set> #include <unordered_map> #include <fstream> #include <functional> #include <random> #include <cassert> using namespace std; typedef long long ll; typedef long double ld; #define ff first #define ss second ll ttt; const ll INF = 1e18; const ll MOD = 1e9 + 7; const ll N = 1007; ll n, m, k; char a[N][N]; ll c[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> ttt; while (ttt--) { cin >> n >> m; fill(c, c + max(n, m), 0); if (n > m) { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = '+'; } } int ans = n; int col = 0; int cur = 0; int ccnt = 0; while (cur < (m + 1) / 2 - 1 && col < m) { bool doneacol = false; for (int i = 0; i < n; i++) { if (c[i] == cur && a[i][col] == '+') { a[i][col] = '-'; c[i]++; ccnt++; if (ccnt > n / 2) { doneacol = true; col++; ccnt = 0; ans++; break; } } } if (!doneacol) { cur++; } } cout << ans << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << a[i][j]; } cout << endl; } } else { for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = '-'; } } int ans = m; int r = 0; int cur = 0; int ccnt = 0; while (cur < (n + 1) / 2 - 1 && r < n) { bool donearow = false; for (int j = 0; j < m; j++) { if (c[j] == cur && a[r][j] == '-') { a[r][j] = '+'; c[j]++; ccnt++; if (ccnt > m / 2) { donearow = true; r++; ccnt = 0; ans++; break; } } } if (!donearow) { cur++; } } cout << ans << endl; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cout << a[i][j]; } cout << endl; } } } return 0; } /// ---- - -------- ------ -------- -- - - - /// Just a reminder. Ubuntu password is I O I /// ---- - -------- ------ -------- -- - - -
#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...