답안 #853876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853876 2023-09-25T11:38:34 Z Trisanu_Das Red-blue table (IZhO19_stones) C++17
100 / 100
24 ms 2384 KB
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int t; cin >> t;
	while(t--){
		int n, m;
		cin >> n >> m;
		char swapped = false;
		if(n < m){
			m ^= n ^= m ^= n;
			swapped = true;
		}
		char b[n][m];
		for(int i = 0; i < n; i++) for(int y = 0; y < m; y++) b[i][y] = '+';
		int ans = n;
		int c = 0, x = 0;
		for(int i = 0; i < (m - 1) / 2; i++){
			for(int y = 0; y < n; y++){
				b[y][x] = '-';
				c++;
				if(c == n / 2 + 1){
					x++;
					c = 0;
					ans++;
				}
			}
		}
		cout << ans << '\n';
		if(!swapped){
			for(int y = 0; y < n; y++){
				for(int x = 0; x < m; x++) cout << b[y][x];
				cout << '\n';
			}
		}
		else{
			for(int y = 0; y < m; y++){
				for(int x = 0; x < n; x++) cout << (b[x][y] == '+' ? '-' : '+');
				cout << '\n';
			}
		}
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 3 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1436 KB Output is correct
2 Correct 20 ms 1880 KB Output is correct
3 Correct 19 ms 1880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 1360 KB Output is correct
2 Correct 19 ms 1624 KB Output is correct
3 Correct 17 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 3 ms 800 KB Output is correct
5 Correct 24 ms 1436 KB Output is correct
6 Correct 20 ms 1880 KB Output is correct
7 Correct 19 ms 1880 KB Output is correct
8 Correct 22 ms 1360 KB Output is correct
9 Correct 19 ms 1624 KB Output is correct
10 Correct 17 ms 1368 KB Output is correct
11 Correct 7 ms 600 KB Output is correct
12 Correct 24 ms 1408 KB Output is correct
13 Correct 18 ms 1548 KB Output is correct
14 Correct 14 ms 1112 KB Output is correct
15 Correct 22 ms 2384 KB Output is correct
16 Correct 17 ms 1880 KB Output is correct
17 Correct 8 ms 856 KB Output is correct