답안 #526554

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
526554 2022-02-15T08:07:47 Z asdf2727 Red-blue table (IZhO19_stones) C++17
53 / 100
33 ms 1224 KB
#include <iostream>

int main() {
	int nrt, sizx, sizy;
	int sizx1, sizx2, sizy1, sizy2;
	int ans;
	std::cin >> nrt;
	while (nrt--) {
		std::cin >> sizx >> sizy;
		if (sizx <= sizy && sizx < 3) {
			std::cout << sizy << '\n';
			for (int index = 0; index < sizx; index++) {
				for (int index2 = 0; index2 < sizy; index2++) {
					std::cout << '-';
				}
				std::cout << '\n';
			}
		}
		else if (sizy < 3) {
			std::cout << sizx << '\n';
			for (int index = 0; index < sizx; index++) {
				for (int index2 = 0; index2 < sizy; index2++) {
					std::cout << '+';
				}
				std::cout << '\n';
			}
		}
		else {
			sizx1 = (sizx - 1) >> 1;
			sizx2 = (sizx >> 1) + 1;
			sizy1 = (sizy - 1) >> 1;
			sizy2 = (sizy >> 1) + 1;
			ans = sizx + sizy + sizx1 + sizy1 - sizx2 - sizy2;
			if (ans < sizy + 3 && (sizx == 5 || sizx == 6)) {
				std::cout << sizy + 3 << '\n';
				for (int index = 0; index < sizy2; index++) {
					std::cout << '+';
				}
				for (int index = sizy2; index < sizy; index++) {
					std::cout << '-';
				}
				std::cout << '\n';
				for (int index = 0; index < sizy1; index++) {
					std::cout << '-';
				}
				for (int index = sizy1; index < sizy; index++) {
					std::cout << '+';
				}
				std::cout << '\n';
				for (int index = 0; index < sizy1; index++) {
					std::cout << '+';
				}
				for (int index = sizy1; index < sizy2; index++) {
					std::cout << '-';
				}
				for (int index = sizy2; index < sizy; index++) {
					std::cout << '+';
				}
				std::cout << '\n';
				for (int index = 3; index < sizx; index++) {
					for (int index2 = 0; index2 < sizy; index2++) {
						std::cout << '-';
					}
					std::cout << '\n';
				}
			}
			else if (ans < sizx + 3 && (sizy == 5 || sizy == 6)) {
				std::cout << sizx + 3 << '\n';
				for (int index = 0; index < sizx1; index++) {
					std::cout << "--+";
					for (int index2 = 3; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
				for (int index = sizx1; index < sizx2; index++) {
					std::cout << "-+-";
					for (int index2 = 3; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
				for (int index = sizx2; index < sizx; index++) {
					std::cout << "+--";
					for (int index2 = 3; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
			}
			else if (ans < sizx + sizy1) {
				std::cout << sizx + sizy1 << '\n';
				for (int index = 0; index < sizx; index++) {
					for (int index2 = 0; index2 < sizy1; index2++) {
						std::cout << '-';
					}
					for (int index2 = sizy1; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
			}
			else if (ans < sizy + sizx1) {
				std::cout << sizy + sizx1 << '\n';
				for (int index = 0; index < sizx1; index++) {
					for (int index2 = 0; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
				for (int index = sizx1; index < sizx; index++) {
					for (int index2 = 0; index2 < sizy; index2++) {
						std::cout << '-';
					}
					std::cout << '\n';
				}
			}
			else {
				std::cout << ans << '\n';
				for (int index = 0; index < sizx1; index++) {
					for (int index2 = 0; index2 < sizy1; index2++) {
						std::cout << '-';
					}
					for (int index2 = sizy1; index2 < sizy; index2++) {
						std::cout << '+';
					}
					std::cout << '\n';
				}
				for (int index = sizx1; index < sizx2; index++) {
					for (int index2 = 0; index2 < sizy; index2++) {
						std::cout << '-';
					}
					std::cout << '\n';
				}
				for (int index = sizx2; index < sizx; index++) {
					for (int index2 = 0; index2 < sizy2; index2++) {
						std::cout << '+';
					}
					for (int index2 = sizy2; index2 < sizy; index2++) {
						std::cout << '-';
					}
					std::cout << '\n';
				}
			}
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Incorrect 3 ms 332 KB in the table A+B is not equal to 7
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 1224 KB Output is correct
2 Correct 27 ms 1152 KB Output is correct
3 Correct 24 ms 1072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 1192 KB Output is correct
2 Correct 24 ms 1100 KB Output is correct
3 Correct 22 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 292 KB Output is correct
3 Correct 2 ms 204 KB Output is correct
4 Incorrect 3 ms 332 KB in the table A+B is not equal to 7
5 Halted 0 ms 0 KB -