QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345603#7661. Japanese Lotteryhht2005WA 71ms3844kbC++141.1kb2024-03-07 10:16:182024-03-07 10:16:18

Judging History

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

  • [2024-03-07 10:16:18]
  • 评测
  • 测评结果:WA
  • 用时:71ms
  • 内存:3844kb
  • [2024-03-07 10:16:18]
  • 提交

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);
		if(x1 > x2) 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;
}

詳細信息

Test #1:

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

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: 3832kb

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: 71ms
memory: 3844kb

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
4
5
6
7
6
7
6
5
6
7
6
5
6
7
6
7
6
5
6
7
6
7
6
5
4
3
4
3
4
5
4
5
6
7
8
9
10
9
10
9
8
9
8
9
8
7
8
9
8
9
8
9
10
9
10
9
10
11
10
11
10
9
10
11
12
11
10
9
10
9
10
11
12
13
14
13
12
13
12
13
12
11
12
13
12
11
12
13
12
13
12
13
14
13
12
11
12
11
10
9
10
9
8
7
6
7
8
9
10
11
10
9
10...

result:

wrong answer 71st lines differ - expected: '9', found: '11'