Submission #898035

#TimeUsernameProblemLanguageResultExecution timeMemory
898035LitusianoRed-blue table (IZhO19_stones)C++17
17 / 100
2052 ms428 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define f first #define s second #define endl '\n' signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--){ int n,m; cin>>n>>m; int BOT = n/2; int BOT1 = m/2; int best = 0; int curans = 0; for(int i = 0; i<(1<<(n*m)); i++){ vector<int> rows(n), columns(m); for(int k = 0; k<(n*m); k++){ if(i & (1<<k)){ // RED // cerr<<k/m<<" "<<n<<endl; rows[k/m]++; } else{ columns[k%m]++; } } int ans = 0; for(int i : rows) ans+= (i>BOT1); for(int i : columns) ans+= i>(BOT); // cout<<ans<<endl; // for(int msk = 0; msk<n*m; msk++){ // if((1<<msk) & i) cout<<'+'; // else cout<<'-'; // if(msk % m == (m-1)) cout<<endl; // } // cout<<"COLUMNS: "; // for(int i : columns) cout<<i<<" "; // cout<<endl<<"ROWS: "; // for(int i : rows) cout<<i<<" "; cout<<endl; if(ans > curans) best = i, curans = ans; } cout<<curans<<endl; for(int i = 0; i<n*m; i++){ if((1<<i) & best) cout<<'+'; else cout<<'-'; if(i % m == (m-1)) cout<<endl; } } } /* 1 3 7 9 10 10 + 24 9 + 11 7 + 4 1 + 3 */
#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...