QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#265756#7740. Puzzle: Question Markucup-team191#WA 216ms9960kbC++142.7kb2023-11-25 20:51:352023-11-25 20:51:35

Judging History

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

  • [2023-11-25 20:51:35]
  • 评测
  • 测评结果:WA
  • 用时:216ms
  • 内存:9960kb
  • [2023-11-25 20:51:35]
  • 提交

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<pii>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=5010,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int t, n, cnt;
int a[N][N];

void postavi (vi v) {
	cnt++;
	for (auto pp : v) {
		int x = pp.first, y = pp.second;
		a[x][y] = cnt;
	}
}

void hor (int x, int y) {
	postavi({{x, y}, {x + 1, y}, {x, y + 1}, {x + 1, y + 2}});
	postavi({{x + 1, y + 1}, {x + 1, y + 3}, {x, y + 2}, {x, y + 3}});
}

void ver (int x, int y) {
	postavi({{x, y}, {x, y + 1}, {x + 1, y + 1}, {x + 2, y}});
	postavi({{x + 1, y}, {x + 2, y + 1}, {x + 3, y}, {x + 3, y + 1}});
}

void tri (int x, int y, int s) {
	postavi({{x, y}, {x + 1 * s, y + 1 * s}, {x + 1 * s, y + 2 * s}, {x, y + 2 * s}});
	postavi({{x, y + 1 * s}, {x + 1 * s, y}, {x + 2 * s, y}, {x + 2 * s, y + 1 * s}});
}

void ispis () {
	cout << cnt << '\n';
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cout << a[i][j];
			if (j < n-1) cout << " ";
		}
		cout << '\n';
	}
}

void solve () {
	int ax = 0, ay = 0;
	int bx = n - 3, by = n - 1;
	for (int br = n / 4 - 1; br >= 1; br--) {
		tri(ax, ay, 1);
		for (int i = 0; i < br; i++) {
			hor(ax, ay + 3 + 4 * i);
			ver(ax + 3 + 4 * i, ay);
		}
		tri(bx, by, -1);
		for (int i = 0; i < br; i++) {
			hor(bx - 1, by - 2 - 4 * (i + 1));
			ver(bx - 2 - 4 * (i + 1), by - 1);
		}
		
		ax += 2; ay += 2;
		bx -= 2; by -= 2;
	}
	tri(ax, ay, 1);
	postavi({{bx, by}, {bx - 1, by - 1}, {bx - 2, by - 1}, {bx - 2, by}});
	for (int i = 0; i < n - 1; i += 4) {
		hor(n - 2, i);
	}
}

int main () {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	while (t--) {
		cin >> n;

		cnt = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				a[i][j] = 0;
			}
		}

		if (n == 1) {
		} else if (n == 3) {
			tri(0, 0, 1);
		} else if (n % 4 == 0) {
			for (int i = 0; i < n; i += 2) {
				for (int j = 0; j < n; j += 4) {
					hor(i, j);
				}
			}
		} else if (n % 4 == 2) {
			for (int i = 0; i < n - 2; i += 2) {
				for (int j = 0; j < n - 2; j += 4) {
					hor(i, j);
				}
			}
			for (int i = 0; i < n - 2; i += 4) {
				hor(n - 2, i);
				ver(i, n - 2);
			}
		} else if (n % 4 == 1) {
			solve();
		} else if (n % 4 == 3) {
			n -= 2;
			solve();
			n += 2;
			int bx = n - 1, by = n - 1;
			tri(bx, by, -1);
			int br = n / 4;
			for (int i = 0; i < br; i++) {
				hor(bx - 1, by - 2 - 4 * (i + 1));
				ver(bx - 2 - 4 * (i + 1), by - 1);
			}
		}
		ispis();
	}
	return 0;
}





Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3664kb

input:

2
3
4

output:

2
1 2 1
2 1 1
2 2 0
4
1 1 2 2
1 2 1 2
3 3 4 4
3 4 3 4

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 216ms
memory: 9960kb

input:

246
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...

output:

0
0
0
0 0
0 0
2
1 2 1
2 1 1
2 2 0
4
1 1 2 2
1 2 1 2
3 3 4 4
3 4 3 4
5
1 2 1 3 3
2 1 1 3 0
2 2 0 0 3
4 4 5 5 0
4 5 4 5 0
8
1 1 2 2 7 7
1 2 1 2 8 7
3 3 4 4 7 8
3 4 3 4 8 8
5 5 6 6 0 0
5 6 5 6 0 0
11
1 2 1 3 3 10 10
2 1 1 3 0 11 10
2 2 0 0 3 10 11
4 4 5 5 0 11 11
4 5 4 5 0 7 7
8 8 9 9 6 6 7
8 9 8 9 6 7...

result:

wrong answer Jury has better answer. Participant 19, jury 20 (test case 9)