# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1190938 | lovrot | Red-blue table (IZhO19_stones) | C++20 | 129 ms | 5192 KiB |
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define deb(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int N = 1010;
const int Z[2] = {'-', '+'};
int n, m;
int ans[N][N];
void task() {
scanf("%d%d", &n, &m);
memset(ans, 0, sizeof(ans));
printf("%d\n", max(m + m * (n - n / 2 - 1) / (m / 2 + 1), n + n * (m - m / 2 - 1) / (n / 2 + 1)));
if(m + m * (n - n / 2 - 1) / (m / 2 + 1) > n + n * (m - m / 2 - 1) / (n / 2 + 1)) {
for(int i = 0, j = 0; i < m * (n - n / 2 - 1) / (m / 2 + 1); ++i) {
for(int k = 0; k < (m / 2 + 1); ++k, j = (j + 1) % m) { ans[i][j] ^= 1; }
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) printf("%c", Z[ans[i][j]]);
printf("\n");
}
} else {
for(int i = 0, j = 0; i < n * (m - m / 2 - 1) / (n / 2 + 1); ++i) {
for(int k = 0; k < (n / 2 + 1); ++k, j = (j + 1) % n) { ans[j][i] ^= 1; }
}
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) printf("%c", Z[1 ^ ans[i][j]]);
printf("\n");
}
}
}
int main() {
int t;
scanf("%d", &t);
for(; t--; ) task();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |