제출 #1171692

#제출 시각아이디문제언어결과실행 시간메모리
1171692coolboy19521Red-blue table (IZhO19_stones)C++20
10 / 100
36 ms1352 KiB
#include "bits/stdc++.h"

#define mxN 1003

using namespace std;

char gr[mxN][mxN];

int main(){
	int T;
	cin >> T;
	
	while (T --){
		int N, M;
		cin >> N >> M;
		
		for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= M; j ++)
			gr[i][j] = "-+"[N >= M];

		int ans = 0;

		if (N >= M){
			for (int i = 1; i <= N / 2 + 1; i ++)
			for (int j = 1; j <= (M + 1) / 2 - 1; j ++)
				gr[i][j] = '-';
			if (M / 2 > 1){
				for (int i = N / 2 + 2; i <= N; i ++)
				for (int j = (M + 1) / 2 - 1; j <= M; j ++)
					gr[i][j] = '-';
				cout << M / 2 * 2 + N - 1 << endl;
			} else cout << N + (M + 1) / 2 - 1 << endl;
		} else {
			for (int i = 1; i <= (N + 1) / 2 - 1; i ++)
			for (int j = 1; j <= M / 2 + 1; j ++)
				gr[i][j] = '+';
			if (N / 2 > 1){
				for (int i = (N + 1) / 2; i <= N / 2 * 2; i ++)
				for (int j = M / 2 + 1; j <= M; j ++)
					gr[i][j] = '+';
				cout << N / 2 * 2 + M - 1 << endl;
			} else cout << M + (N + 1) / 2 - 1 << endl;
		}
		
		for (int i = 1; i <= N; i ++){
			for (int j = 1; j <= M; j ++)
				cout << gr[i][j];
			cout << endl;
		}
	}
}
#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...