QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741331#6309. AqreOIer_kzc#WA 2ms6756kbC++171.8kb2024-11-13 14:06:462024-11-13 14:06:46

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 14:06:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6756kb
  • [2024-11-13 14:06:46]
  • 提交

answer

#include <stdio.h>
#include <string.h>
#include <assert.h>

#include <queue>
#include <algorithm>

#define LOG(FMT...) fprintf(stderr, FMT)

#define eb emplace_back
#define em emplace

using namespace std;

typedef long long LL;
constexpr int N = 1024;
constexpr int rem[4] = {3, 1, 2, 0};

char gr[N][N];
int a[N][N];

int main() {
	int n = 1020, m = 1020;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			gr[i + 1][j + 1] = "01"[(j & 3) != rem[i & 3]];
			a[i + 1][j + 1] = (gr[i + 1][j + 1] == '#') + a[i + 1][j] + a[i][j + 1] - a[i][j];
		}
	}
	int task;
	for (scanf("%d", &task); task--; ) {
		scanf("%d%d", &n, &m);
		if (n < 4 && m < 4) {
			printf("%d\n", n * m);
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < m; ++j) {
					putchar('1');
				}
				puts("");
			}
		} else if (n == 3) {
			printf("%d\n", n * (m - m / 4) - (m % 4 >= 2));
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < m; ++j) {
					putchar("01"[(j & 3) != rem[i & 1]]);
				}
				puts("");
			}
		} else if (m == 3) {
			printf("%d\n", m * (n - n / 4) - (n % 4 >= 2));
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < m; ++j) {
					putchar("01"[(i & 3) != rem[j & 1]]);
				}
				puts("");
			}
		} else {
			int res = 0, rx = -1, ry = -1;
			for (int x = 0; x < 4; ++x) {
				for (int y = 0; y < 4; ++y) {
					int v = a[x + n][y + m] - a[x + n][y] - a[x][y + m] + a[x][y];
					if (v <= res) {
						continue;
					}
					res = v, rx = x, ry = y;
				}
			}
			printf("%d\n", res);
			// LOG("%d\n", min(n * (m - m / 4), m * (n - n / 4)));
			// LOG("+(%d, %d)\n", rx, ry);
			for (int i = 1; i <= n; ++i) {
				for (int j = 1; j <= m; ++j) {
					putchar(gr[rx + i][ry + j]);
				}
				puts("");
			}
		}
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 6756kb

input:

3
2 2
3 4
3 8

output:

4
11
11
9
1110
1011
1110
18
11101110
10111011
11101110

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 6740kb

input:

361
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
2 16
2 17
2 18
2 19
2 20
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
3 13
3 14
3 15
3 16
3 17
3 18
3 19
3 20
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
4 13
4 14
4 15
4 16
4 17
4 18
4 19
4 20
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
5 1...

output:

4
11
11
6
111
111
0

result:

wrong answer Token parameter [name=s[i]] equals to " (test case 3)