제출 #879038

#제출 시각아이디문제언어결과실행 시간메모리
879038Elvin_FritlRed-blue table (IZhO19_stones)C++17
0 / 100
57 ms2452 KiB
#include <bits/stdc++.h> using namespace std; #define io \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); typedef long long ll; ll bp(ll n,ll m){ if(m == 0){ return 1; } if(m == 1){ return n; } if(m%2==0){ return bp(n*n,m/2); } return n*bp(n,m-1); } const int N = 1020, M = 33, inf = 1e9 + 99; const ll inff = 1e12; int main() { io; int t; cin >> t; while(t--) { int n , m; cin >> n >> m; vector<vector<char>> v(n , vector<char>(m)); char cc = '+'; if(n > m) { cc = '-'; } vector<vector<char>> tmp(n , vector<char>(m , cc)); int ans = max(n , m); int fi[n]={0} , se[m] = {0}; for(int i=0;i<m;i++) { v[0][i] = '-'; se[i] ++; } for(int i=1;i<n;i++) { v[i][0] = '+'; fi[i] ++; } for(int i=1;i<n;i++) { for(int j=1;j<m;j++) { if((j + i)%2 == 0) { v[i][j] = '+'; fi[i] ++; } else { v[i][j] = '-'; se[j] ++; } } } int res = 0; for(int i=0;i<n;i++) { res += (fi[i] > n/2); } for(int i=0;i<m;i++) { res += (se[i] > n/2); } if(res < ans) { res = ans; v = tmp; } cout << res << endl; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cout << v[i][j] << " "; } cout << endl; } } 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...