답안 #336629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
336629 2020-12-16T04:36:04 Z Gurban Red-blue table (IZhO19_stones) C++17
100 / 100
69 ms 2412 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const int maxn=1e3+5;
int tt;
int n,m,ans,b,a,tr;
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;
		tr = 0;
		if(n < m) swap(n,m),tr=1;
		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);
		while(!q.empty()) q.pop();
		for(int i = 1;i <= n;i++) if(b) 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';
		if(tr) swap(n,m);
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= m;j++){
				if(tr){
					if(c[j][i]=='-') c[j][i]='+';
					else c[j][i]='-';
					cout<<c[j][i];
				}
				else cout<<c[i][j];
			}
			cout<<'\n';
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1516 KB Output is correct
2 Correct 65 ms 2180 KB Output is correct
3 Correct 58 ms 2156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 1536 KB Output is correct
2 Correct 57 ms 2028 KB Output is correct
3 Correct 51 ms 1644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 68 ms 1516 KB Output is correct
6 Correct 65 ms 2180 KB Output is correct
7 Correct 58 ms 2156 KB Output is correct
8 Correct 62 ms 1536 KB Output is correct
9 Correct 57 ms 2028 KB Output is correct
10 Correct 51 ms 1644 KB Output is correct
11 Correct 13 ms 620 KB Output is correct
12 Correct 54 ms 1900 KB Output is correct
13 Correct 57 ms 2156 KB Output is correct
14 Correct 42 ms 1772 KB Output is correct
15 Correct 69 ms 2412 KB Output is correct
16 Correct 53 ms 2156 KB Output is correct
17 Correct 27 ms 1388 KB Output is correct