Submission #424183

#TimeUsernameProblemLanguageResultExecution timeMemory
424183dooweyRed-blue table (IZhO19_stones)C++14
54 / 100
67 ms2904 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define fi first #define se second #define mp make_pair #define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); const int N = 1010; vector<vector<char>> get(int n, int m, int &sol){ vector<vector<char>> sos; sos.resize(n); for(int i = 0 ; i < n; i ++ ){ for(int j = 0 ; j < m ; j ++ ){ sos[i].push_back('-'); } } for(int i = 0 ; i < n; i ++ ){ for(int j = 0; j < (m + 2) / 2; j ++ ){ sos[i][j] = '+'; } } int xx; int take; if(m % 2 == 1){ take = m/2 - 1; } else{ take = (m+2)/2 - 4; } for(int jj = 0 ; jj < take; jj ++ ){ xx = jj-1; for(int id = 0; id < (n + 2) / 2; id ++ ){ xx ++ ; xx %= (m - 1)/2; sos[id][jj] = '-'; sos[id][xx+(m+2)/2] = '+'; } } sol = 0; int cnt; for(int i = 0 ; i < n; i ++ ){ cnt = 0; for(int j = 0 ; j < m ; j ++ ){ if(sos[i][j] == '+'){ cnt ++ ; } } if(cnt >= (m + 2) / 2){ sol ++ ; } } for(int j = 0 ; j < m ; j ++ ){ cnt = 0; for(int i = 0 ; i < n; i ++ ){ if(sos[i][j] == '-'){ cnt ++ ; } } if(cnt >= (n + 2) / 2){ sol ++ ; } } return sos; } void solve(){ int n, m; cin >> n >> m; int res1 = 0; int res2 = 0; vector<vector<char>> s1 = get(n, m, res1); vector<vector<char>> s2 = get(m, n, res2); if(res1 >= res2){ cout << res1 << "\n"; for(auto x : s1){ for(auto y : x){ cout << y; } cout << "\n"; } } else{ cout << res2 << "\n"; for(int i = 0 ; i < n; i ++ ){ for(int j = 0 ; j < m ; j ++ ){ if(s2[j][i] == '-'){ s2[j][i] = '+'; } else{ s2[j][i] = '-'; } cout << s2[j][i]; } cout << "\n"; } } } int main(){ fastIO; //freopen("in.txt","r",stdin); int tc; cin >> tc; for(int iq = 1; iq <= tc; iq ++ ){ 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...