Submission #526557

# Submission time Handle Problem Language Result Execution time Memory
526557 2022-02-15T08:12:04 Z asdf2727 Red-blue table (IZhO19_stones) C++17
69 / 100
32 ms 1248 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) && sizy > 4) {
				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) && sizx > 4) {
				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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 276 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1248 KB Output is correct
2 Correct 26 ms 1096 KB Output is correct
3 Correct 30 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1248 KB Output is correct
2 Correct 23 ms 1088 KB Output is correct
3 Correct 25 ms 996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 276 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 31 ms 1248 KB Output is correct
6 Correct 26 ms 1096 KB Output is correct
7 Correct 30 ms 1088 KB Output is correct
8 Correct 32 ms 1248 KB Output is correct
9 Correct 23 ms 1088 KB Output is correct
10 Correct 25 ms 996 KB Output is correct
11 Incorrect 11 ms 452 KB Wrong answer in test 26 8: 30 < 31
12 Halted 0 ms 0 KB -