Submission #908542

#TimeUsernameProblemLanguageResultExecution timeMemory
908542SalihSahinRed-blue table (IZhO19_stones)C++14
0 / 100
66 ms1364 KiB
#include<bits/stdc++.h> #define int long long #define pb push_back #define mp make_pair using namespace std; const int mod = 1e9 + 7; const int inf = 1e12*2; const int N = 2e5 + 5; int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int t; cin>>t; while(t--){ int n, m; cin>>n>>m; int type1 = n + ((m - (m/2 + 1)) * n) / (n/2 + 1); int type2 = m + ((n - (n/2 + 1)) * m) / (m/2 + 1); cout<<max(type1, type2)<<endl; if(type1 >= type2){ vector<vector<char> > a(n, vector<char>(m, '+')); priority_queue<pair<int, int> > pq; for(int i = 0; i < n; i++){ pq.push(mp(0LL, i)); } int cnt = n/2 + 1; int limit = m - (m/2 + 1); for(int j = 0; j < m; j++){ for(int i = 0; i < cnt; i++){ if(!pq.size()) break; int xc = pq.top().first * (-1), pos = pq.top().second; a[pos][j] = '-'; xc++; pq.pop(); if(xc < limit) pq.push(mp(xc * (-1), pos)); } } for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout<<a[i][j]; } cout<<endl; } } else{ vector<vector<char> > a(n, vector<char>(m, '+')); priority_queue<pair<int, int> > pq; for(int i = 0; i < n; i++){ pq.push(mp(0LL, i)); } int cnt = n/2 + 1; int limit = m - (m/2 + 1); for(int j = 0; j < m; j++){ for(int i = 0; i < cnt; i++){ if(!pq.size()) break; int xc = pq.top().first * (-1), pos = pq.top().second; a[pos][j] = '-'; xc++; pq.pop(); if(xc < limit) pq.push(mp(xc * (-1), pos)); } } for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ cout<<a[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...