제출 #1128308

#제출 시각아이디문제언어결과실행 시간메모리
1128308atillamaRed-blue table (IZhO19_stones)C++20
0 / 100
21 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){ 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 - 1 > 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...