Submission #424192

#TimeUsernameProblemLanguageResultExecution timeMemory
424192dooweyRed-blue table (IZhO19_stones)C++14
100 / 100
67 ms3272 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; for(int jj = 0 ; jj < (m + 2) / 2; jj ++ ){ if((jj + 1) * ((n + 2) / 2) > ((m - 1) / 2) * ((n - 1) / 2)) break; 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; }

Compilation message (stderr)

stones.cpp: In function 'std::vector<std::vector<char> > get(int, int, int&)':
stones.cpp:30:9: warning: unused variable 'take' [-Wunused-variable]
   30 |     int take;
      |         ^~~~
#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...