답안 #857018

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
857018 2023-10-05T08:40:25 Z Halym2007 Red-blue table (IZhO19_stones) C++11
11 / 100
24 ms 2148 KB
#include <iostream>
#include <algorithm>
#include <math.h>
//#include <vector>
//#include <stack>
//#include <queue>
//#include <map>
//#include <set>
//#include <deque>
#define ll long long
#define sz(s) (int)s.size()
#define N 200005
#define ff first
#define ss second
using namespace std;
int T, n, m;
char c[1005][1005];
int main()
{
	cin >> T;
	while(T--){
		cin >> n >> m;
		if(m % 2 == 1){
			if(n == 1){
				cout << m << '\n';
				for(int i = 1; i <= m; i++){
					cout << '-';
				}
				cout << '\n';
				continue;
			}
			else if(m == 1){
				cout << n << '\n';
				for(int i = 1; i <= n; i++){
					cout << '+' << '\n';
				}
				continue;
			}
			else {
				cout << n+m-2 << '\n';
			}
			for(int i = 1; i <= n; i += 2){
				for(int j = 1; j <= m; j++){
					if(j % 2 == 1) c[i][j] = '+';
					else c[i][j] = '-';
				}
			}
			for(int i = 2; i <= n; i += 2){
				for(int j = 1; j <= m; j++){
					if(j % 2 == 1) c[i][j] = '-';
					else c[i][j] = '+';
				}
			}
			for(int i = 1; i <= m; i++){
				c[n][i] = '-';
			}
			for(int i = 1; i <= n; i++){
				c[i][m] = '+';
			}
			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= m; j++){
					cout << c[i][j];
				}
				cout << '\n';
			}
		}
		else {
			if(n == 2){
				cout << 2 << '\n';
			}
			else {
				cout << n+m-4 << '\n';
			}
			for(int i = 1; i <= n; i++){
				c[i][1] = '+';
				c[i][2] = '+';
			}
			for(int i = 1; i <= m; i++){
				c[n-1][i] = '-';
				c[n][i] = '-';
			}
			for(int i = 1; i <= n-2; i++){
				for(int j = 3; j <= m; j++){
					if(i % 2 == 1){
						if(j % 2 == 1){
							c[i][j] = '-';
						}
						else {
							c[i][j] = '+';
						}
					}
					else {
						if(j % 2 == 1){
							c[i][j] = '+';
						}
						else {
							c[i][j] = '-';
						}
					}
				}
			}
			for(int i = 1; i <= n; i++){
				for(int j = 1; j <= m; j++){
					cout << c[i][j];
				}
				cout << '\n';
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Wrong answer in test 20 2: 18 < 20
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 1
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1776 KB Output is correct
2 Correct 20 ms 1884 KB Output is correct
3 Correct 24 ms 2148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 1364 KB Wrong answer in test 4 4: 4 < 5
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB in the table A+B is not equal to 1
3 Halted 0 ms 0 KB -