제출 #336627

#제출 시각아이디문제언어결과실행 시간메모리
336627GurbanRed-blue table (IZhO19_stones)C++17
15 / 100
69 ms1828 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int maxn=1e3+5; int tt; int n,m,ans,b,a; char c[maxn][maxn]; priority_queue<pair<int,int>>q; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> tt; while(tt--){ cin >> n >> m; if(min(n,m) <= 2){ if(n >= m) for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '+'; else for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '-'; cout<<max(n,m)<<'\n'; for(int i = 1;i <= n;i++){ for(int j = 1;j <= m;j++) cout<<c[i][j]; cout<<'\n'; } continue; } for(int i = 1;i <= n;i++) for(int j = 1;j <= m;j++) c[i][j] = '+'; b = (m-1)/2; a = n/2+1; ans = n + ((n*b)/a); // cout<<a<<'\n'; while(!q.empty()) q.pop(); for(int i = 1;i <= n;i++) q.push({b,i}); for(int i = 1;i <= m;i++){ for(int j = 1;j <= a;j++){ if(q.empty()) break; pair<int,int>x=q.top(); q.pop(); c[x.second][i] = '-'; if(x.first > 1) q.push({x.first-1,x.second}); } } cout<<ans<<'\n'; for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ cout<<c[i][j]; } cout<<'\n'; } } }
#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...