Submission #908544

#TimeUsernameProblemLanguageResultExecution timeMemory
908544SalihSahinRed-blue table (IZhO19_stones)C++17
100 / 100
67 ms2240 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, '+')); int cnt = n/2 + 1; int limit = m - (m/2 + 1); priority_queue<pair<int, int> > pq; for(int i = 0; i < n; i++){ if(limit == 0) break; pq.push(mp(0LL, i)); } 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, '-')); int cnt = m/2 + 1; int limit = n - (n/2 + 1); priority_queue<pair<int, int> > pq; for(int i = 0; i < m; i++){ if(limit == 0) break; pq.push(mp(0LL, i)); } for(int j = 0; j < n; j++){ for(int i = 0; i < cnt; i++){ if(!pq.size()) break; int xc = pq.top().first * (-1), pos = pq.top().second; a[j][pos] = '+'; 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...