답안 #372340

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
372340 2021-02-27T17:31:31 Z mariowong Red-blue table (IZhO19_stones) C++14
100 / 100
42 ms 3308 KB
#include <bits/stdc++.h>
using namespace std;

int t,n,m,pos,num,anss1,anss2,ct1[1005],ct2[1005];
char ans1[1005][1005],ans2[1005][1005];
int main(){
	ios::sync_with_stdio(false);
	cin >> t;
	while (t--){
		cin >> n >> m;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m;j++){
				ans1[i][j]='+';
				ans2[i][j]='-';
				ct2[j]=0;
			}
			ct1[i]=0;
		}
		pos=1; anss1=n;
		for (int i=1;i<=m;i++){
			for (int j=1;j<=n/2+1;j++){
				if (ct1[pos]+1 >= (m+1)/2)
				goto out;
				ans1[pos][i]='-';
				ct1[pos]++;
				pos++; 
				if (pos == n+1)
				pos=1;
			}	
			anss1++;
		}
		out:;
		
		pos=1; anss2=m;
		for (int i=1;i<=n;i++){
			for (int j=1;j<=m/2+1;j++){
				if (ct2[pos]+1 >= (n+1)/2)
				goto out2;
				ans2[i][pos]='+';
				ct2[pos]++;
				pos++; 
				if (pos == m+1)
				pos=1;
			}
			anss2++;	
		}
		out2:;
		cout << max(anss1,anss2) << "\n";
		if (anss1 > anss2){
			for (int i=1;i<=n;i++){
				for (int j=1;j<=m;j++){
					cout << ans1[i][j];
				}
				cout << "\n";
			}
		}
		else
		{
			for (int i=1;i<=n;i++){
				for (int j=1;j<=m;j++){
					cout << ans2[i][j];
				}
				cout << "\n";
			}
		}
	}
    return 0;
}	
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 492 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 2 ms 492 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1644 KB Output is correct
2 Correct 35 ms 2796 KB Output is correct
3 Correct 34 ms 3052 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1624 KB Output is correct
2 Correct 39 ms 2668 KB Output is correct
3 Correct 29 ms 2284 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 2 ms 492 KB Output is correct
4 Correct 3 ms 492 KB Output is correct
5 Correct 40 ms 1644 KB Output is correct
6 Correct 35 ms 2796 KB Output is correct
7 Correct 34 ms 3052 KB Output is correct
8 Correct 42 ms 1624 KB Output is correct
9 Correct 39 ms 2668 KB Output is correct
10 Correct 29 ms 2284 KB Output is correct
11 Correct 12 ms 620 KB Output is correct
12 Correct 32 ms 2668 KB Output is correct
13 Correct 33 ms 2924 KB Output is correct
14 Correct 26 ms 2412 KB Output is correct
15 Correct 39 ms 3308 KB Output is correct
16 Correct 29 ms 2688 KB Output is correct
17 Correct 13 ms 2028 KB Output is correct