제출 #1156568

#제출 시각아이디문제언어결과실행 시간메모리
1156568UmairAhmadMirzaRed-blue table (IZhO19_stones)C++20
27 / 100
48 ms1352 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int const N=2e5+5; int const mod=1e9+7; int n,m; int calcu(vector<vector<bool>> v){ // cout<<n<<' '<<m<<endl; int a=0; for(int i=0;i<n;i++){ int c=0; for(int j=0;j<m;j++) if(v[i][j]==1) c++; if(c*2>m) a++; } for(int j=0;j<m;j++){ int c=0; for(int i=0;i<n;i++){ if(v[i][j]==0) c++; } if(c*2>n) a++; } return a; } // int oddodd(){ // cout<<(n+m)-2<<endl; // int hn=1+(n/2),hm=(m/2)+1; // for(int i=0;i<n;i++){ // for(int j=0;j<m;j++){ // if(j<=()) // } // } // } void solve(){ // int n,m; cin>>n>>m; if(min(n,m)<=4){ int hm=(m/2)+1,hn=(n/2)+1; if(m+(n-hn)>(n+(m-hm))){ cout<<m+(n-hn)<<endl; for (int i = 1; i <=n; ++i) { for(int j=1;j<=m;j++){ if(j<=hm && i<=(n-hn)) cout<<'+'; else cout<<'-'; } cout<<endl; } } else{ cout<<n+(m-hm)<<endl; for (int i = 1; i <=n; ++i) { for(int j=1;j<=m;j++){ if(i<=hn && j<=(m-hm)) cout<<'-'; else cout<<'+'; } cout<<endl; } } return; } int hm=(m/2)+1,hn=(n/2)+1; cout<<hm<<' '<<hn<<endl; vector<vector<bool>> a1,a2; for(int i=1;i<=n;i++){ a1.push_back({}); for(int j=1;j<=m;j++){ if((j<=hm && i<=(n-hn)) || (i>hn && j>(m-hm))) a1[i-1].push_back(1); else a1[i-1].push_back(0); } } for(int i=1;i<=n;i++){ a2.push_back({}); for(int j=1;j<=m;j++){ if((i<=hn && j<=(m-hm)) || (j>hm && i>(n-hn))) a2[i-1].push_back(0); else a2[i-1].push_back(1); } } int aa1=calcu(a1),aa2=calcu(a2); // cout<<aa1<<' '<<aa2<<endl; if(aa1<aa2) swap(a1,a2); cout<<max(aa1,aa2)<<endl; string st="-+"; for (int i = 0; i < n; ++i){ for (int j = 0; j < m; ++j) cout<<st[a1[i][j]]; cout<<endl; } } int main(){ int t; cin>>t; while(t--) solve(); }
#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...