Submission #526392

# Submission time Handle Problem Language Result Execution time Memory
526392 2022-02-14T15:23:26 Z asdf2727 Red-blue table (IZhO19_stones) C++17
38 / 100
38 ms 1252 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 < 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 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 324 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1188 KB Output is correct
2 Correct 31 ms 1108 KB Output is correct
3 Correct 29 ms 1252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 1180 KB Wrong answer in test 6 6: 8 < 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 2 ms 324 KB Wrong answer in test 38 5: 40 < 41
5 Halted 0 ms 0 KB -