QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#345598#7661. Japanese Lotteryhht2005WA 72ms3936kbC++141.0kb2024-03-07 10:11:542024-03-07 10:11:55

Judging History

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

  • [2024-03-07 10:11:55]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:3936kb
  • [2024-03-07 10:11:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int pos[N << 2][22], ans[22], w;
void build(int p, int l, int r) {
	for(int i = 1; i <= w; i++)
		pos[p][i] = i;
	if(l == r)return;
	int mid = (l + r) >> 1;
	build(p << 1, l, mid);
	build(p << 1 | 1, mid + 1, r);
}
void modify(int p, int l, int r, int x, int v) {
	if(l == r) {
		swap(pos[p][v], pos[p][v + 1]);
		return;
	}
	int mid = (l + r) >> 1;
	if(x <= mid)modify(p << 1, l, mid, x, v);
	else modify(p << 1 | 1, mid + 1, r, x, v);
	for(int i = 1; i <= w; i++)
		pos[p][pos[p << 1 | 1][i]] = pos[p << 1][i];
}
int main() {
	int h, q, y, x1, x2;
	scanf("%d%d%d", &w, &h, &q);
	build(1, 1, h);
	while(q--) {
		scanf("%d%d%d", &y, &x1, &x2);
		modify(1, 1, h, y, x1);
		int cnt = 0;
		for(int i = 1; i <= w; i++)
			ans[i] = pos[1][i];
		for(int i = 1; i <= w; i++) {
			if(ans[i] == i)continue;
			for(int j = i + 1; j <= w; j++) {
				if(ans[j] == i) {
					swap(ans[i], ans[j]);
					break;
				}
			}
			cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 6 7
1 1 2
2 3 4
4 3 4
5 1 2
6 3 4
3 2 3
6 3 4

output:

1
2
1
0
1
2
1

result:

ok 7 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 3936kb

input:

5 9 12
1 3 4
2 1 2
3 2 3
4 4 5
5 2 1
6 4 3
7 2 3
8 4 3
9 4 5
6 4 3
7 2 3
1 3 4

output:

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

result:

ok 12 lines

Test #3:

score: -100
Wrong Answer
time: 72ms
memory: 3780kb

input:

20 60 200000
49 11 10
18 6 7
24 4 5
56 10 9
14 19 18
44 2 3
4 3 4
24 4 5
30 4 5
56 10 9
44 2 3
50 10 9
43 6 7
50 9 10
18 7 6
13 16 17
57 16 15
52 7 6
55 7 8
10 18 19
47 17 16
11 11 12
33 17 18
7 11 10
57 15 16
45 9 8
47 17 16
56 17 16
10 18 19
19 5 4
21 9 8
53 10 11
22 8 9
4 4 3
13 16 17
7 11 10
4 8...

output:

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

result:

wrong answer 14th lines differ - expected: '4', found: '6'