Submission #1128313

#TimeUsernameProblemLanguageResultExecution timeMemory
1128313atillamaRed-blue table (IZhO19_stones)C++20
0 / 100
20 ms1348 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) const double eps = 1e-9; const int mod = 1e9 + 7; const int N = 1e3 + 5; signed main(){ fastio; int t; cin >> t; while(t--){ int n, m; cin >> n >> m; if(n <= m / 2){ vector<vector<char>> arr(n, vector<char>(m, '-')); cout << m << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << arr[i][j]; } cout << '\n'; } continue; } if(n / 2 >= m){ vector<vector<char>> arr(n, vector<char>(m, '+')); cout << n << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << arr[i][j]; } cout << '\n'; } continue; } if(n <= m){ vector<vector<char>> arr(n, vector<char>(m, '-')); vector<pair<int, int>> setirler(n, {m, 0}); // - lerin sayi, + lerin sayi vector<pair<int, int>> sutunlar(m, {n, 0}); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(setirler[i].first >= setirler[i].second && sutunlar[j].first - 2 > sutunlar[j].second){ arr[i][j] = '+'; setirler[i].first--; setirler[i].second++; sutunlar[j].first--; sutunlar[j].second++; } } } int ans = 0; for(int i = 0; i < n; i++){ if(setirler[i].first < setirler[i].second){ ans++; } } for(int j = 0; j < m; j++){ if(sutunlar[j].first > sutunlar[j].second){ ans++; } } cout << ans << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << arr[i][j]; } cout << '\n'; } }else{ vector<vector<char>> arr(n, vector<char>(m, '+')); vector<pair<int, int>> setirler(n, {0, m}); // - lerin sayi, + lerin sayi vector<pair<int, int>> sutunlar(m, {0, n}); for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ if(sutunlar[j].first >= sutunlar[j].second && setirler[i].second - 1 > setirler[i].first){ arr[i][j] = '-'; setirler[i].second--; setirler[i].first++; sutunlar[j].second--; sutunlar[j].first++; } } } int ans = 0; for(int i = 0; i < n; i++){ if(setirler[i].second > setirler[i].first){ ans++; } } for(int j = 0; j < m; j++){ if(sutunlar[j].first > sutunlar[j].second){ ans++; } } cout << ans << '\n'; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout << arr[i][j]; } cout << '\n'; } } } } /* freopen("x.in", "r", stdin); freopen("x.out", "w", stdout); */ //atilla
#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...