QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#492558#169. Donut DecorationAfterlife#AC ✓201ms21760kbC++141.4kb2024-07-26 13:40:282024-07-26 13:40:28

Judging History

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

  • [2024-07-26 13:40:28]
  • 评测
  • 测评结果:AC
  • 用时:201ms
  • 内存:21760kb
  • [2024-07-26 13:40:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 200020
typedef long long ll;
int n,k,m; 
vector<pair<int,int> > c[N];
set<pair<int,int> > S;
bool check(pair<int,int> x,pair<int,int> y){
	return x.first<y.first&&x.second<y.second;
} 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	cin>>m;
	for(int i=1;i<=m;++i){
		int l,r,x;
		cin>>l>>r>>x;
		c[l].emplace_back(x,i);
		c[r+1].emplace_back(x,-i);
	} 
	int bad=0,ans=0;
	for(int i=1;i<=n;++i){
		for(auto [x,t]:c[i]){
			auto w=make_pair(x,t);
			auto pre=make_pair(0,0);
			auto suf=make_pair(0,0);
			if(t<0){
				w.second=-w.second;
				S.erase(w);
				auto it=S.lower_bound(w);
				if(it!=S.end()){
					suf=*it;
				}
				if(it!=S.begin()){
					pre=*--it;
				} 
				if(pre.first&&!check(pre,w)){
					--bad;
				}
				if(suf.first&&!check(w,suf)){
					--bad;
				}
				if(pre.first&&suf.first&&!check(pre,suf)){
					++bad;
				}
			}
			else{
				auto it=S.lower_bound(w);
				if(it!=S.end()){
					suf=*it;
				}
				if(it!=S.begin()){
					pre=*--it;
				} 
				if(pre.first&&!check(pre,w)){
					++bad;
				}
				if(suf.first&&!check(w,suf)){
					++bad;
				}
				if(pre.first&&suf.first&&!check(pre,suf)){
					--bad;
				}
				S.insert(w);
			} 
		}
		if(!bad&&S.size()==k){
			++ans;
		} 
	} 
	cout<<ans<<'\n';
	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 2
3
1 2 1
2 3 2
3 3 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 8332kb

input:

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

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 8244kb

input:

10 1
2
2 9 1
5 7 1

output:

5

result:

ok single line: '5'

Test #4:

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

input:

100 335
500
6 99 1
6 96 2
3 49 327
3 67 3
14 93 4
22 55 5
56 98 5
3 71 6
4 49 49
5 11 59
19 76 7
29 100 8
19 98 9
47 86 10
57 80 11
38 50 37
4 36 229
17 56 11
12 74 12
10 96 13
22 39 181
27 36 279
4 97 14
46 62 15
75 89 23
86 89 168
51 61 16
63 75 15
62 99 16
18 64 17
36 82 18
58 94 19
28 52 75
14 4...

output:

6

result:

ok single line: '6'

Test #5:

score: 0
Accepted
time: 2ms
memory: 8352kb

input:

100 354
500
14 81 1
70 70 1
11 92 2
17 95 3
49 76 4
53 64 5
5 100 6
14 50 164
7 78 7
9 40 176
7 89 8
6 90 9
23 89 10
11 77 11
30 47 273
23 69 12
17 80 13
33 94 14
9 90 15
22 56 307
6 17 96
13 95 16
69 77 85
58 92 17
37 78 18
30 31 71
24 95 19
15 93 20
53 72 21
8 92 22
4 99 23
53 60 24
9 51 172
6 92 ...

output:

1

result:

ok single line: '1'

Test #6:

score: 0
Accepted
time: 2ms
memory: 8424kb

input:

100 329
500
14 100 1
7 67 2
53 62 3
8 97 4
1 98 5
59 97 57
9 98 6
41 78 7
2 98 8
1 13 208
7 91 9
28 66 10
28 80 11
7 68 12
2 86 13
2 60 14
6 90 15
52 97 16
18 94 17
34 100 18
7 97 19
3 100 20
82 100 270
19 92 21
50 92 22
37 42 58
16 74 23
24 99 24
32 47 59
43 88 25
8 49 240
37 47 137
1 34 76
6 100 2...

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 2ms
memory: 8232kb

input:

100 343
500
40 89 1
44 64 2
20 22 321
23 39 15
66 89 109
28 86 3
2 93 4
85 100 126
12 30 298
81 97 121
43 87 5
21 97 6
31 86 7
18 40 299
2 100 8
2 99 9
24 100 10
50 64 11
9 96 12
12 87 13
1 100 14
74 93 33
28 97 15
12 85 16
49 96 17
2 100 18
25 100 19
24 92 20
36 98 21
4 97 22
38 98 23
67 77 1
36 83...

output:

2

result:

ok single line: '2'

Test #8:

score: 0
Accepted
time: 2ms
memory: 8272kb

input:

100 337
500
5 15 136
1 100 1
3 97 2
2 55 3
1 78 4
2 99 5
45 92 6
35 81 7
12 100 8
13 93 9
76 100 145
74 95 162
40 47 235
78 100 118
20 98 10
39 58 11
5 59 12
49 71 13
46 93 14
44 87 15
13 69 16
42 97 17
11 94 18
17 99 19
26 39 83
46 55 20
6 68 21
1 96 22
43 50 23
26 73 24
1 99 25
43 63 26
30 97 27
3...

output:

1

result:

ok single line: '1'

Test #9:

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

input:

100 344
500
65 89 298
2 97 1
23 96 2
15 96 3
8 94 4
10 100 5
2 98 6
5 76 7
8 92 8
15 70 9
6 6 206
4 94 10
15 61 11
15 100 12
10 50 13
2 21 49
48 82 13
10 23 35
35 100 14
10 91 15
4 100 16
20 87 17
1 7 344
26 98 18
49 66 19
21 30 26
12 51 19
15 93 20
22 96 21
24 91 22
43 76 23
30 81 24
1 96 25
24 60 ...

output:

5

result:

ok single line: '5'

Test #10:

score: 0
Accepted
time: 1ms
memory: 8408kb

input:

100 345
500
13 43 1
6 93 2
2 92 3
2 95 4
5 86 5
27 100 6
7 21 126
16 84 7
27 67 8
63 81 148
32 77 9
4 31 271
2 99 10
5 39 11
23 95 12
14 97 13
45 52 312
25 100 14
13 64 15
27 59 16
2 96 17
64 80 150
24 61 18
22 71 19
27 69 20
7 87 21
14 25 256
32 35 61
39 94 22
18 99 23
28 72 24
63 78 207
34 52 25
9...

output:

1

result:

ok single line: '1'

Test #11:

score: 0
Accepted
time: 2ms
memory: 8276kb

input:

100 307
500
4 17 40
4 94 1
30 94 2
3 57 2
25 79 3
37 97 4
35 49 238
9 37 4
25 72 5
54 63 129
34 74 6
5 61 6
18 100 7
62 74 8
22 30 8
22 68 9
65 97 9
12 98 10
2 100 11
27 36 165
6 63 12
34 96 12
18 99 13
31 93 14
3 67 14
17 76 15
17 98 16
81 100 123
23 38 17
66 84 17
7 100 18
11 91 19
1 100 20
46 100...

output:

2

result:

ok single line: '2'

Test #12:

score: 0
Accepted
time: 2ms
memory: 8432kb

input:

100 342
500
42 45 267
27 88 1
45 63 2
19 91 3
44 55 4
37 94 5
18 79 6
58 82 129
72 79 100
7 99 7
98 98 334
25 56 8
87 90 282
19 66 9
35 95 10
4 52 11
51 95 12
33 60 13
22 97 14
23 88 15
25 72 16
29 71 17
38 79 18
5 100 19
19 37 298
28 55 20
18 31 133
6 71 21
36 89 22
39 96 23
1 54 24
55 79 193
40 76...

output:

1

result:

ok single line: '1'

Test #13:

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

input:

100 350
500
43 73 1
45 73 2
11 26 26
77 86 155
4 98 3
29 29 263
51 98 4
57 94 5
9 91 6
7 14 129
37 65 7
4 100 8
8 92 9
29 38 87
11 84 10
53 83 11
1 92 12
16 24 99
41 93 13
6 96 14
26 80 15
1 99 16
2 100 17
7 81 18
12 68 19
3 99 20
2 99 21
31 64 22
70 98 288
19 86 23
1 78 24
8 95 25
29 73 26
7 96 27
...

output:

1

result:

ok single line: '1'

Test #14:

score: 0
Accepted
time: 199ms
memory: 21664kb

input:

200000 138640
200000
46214 50085 12931
97605 144797 1
134078 172961 47035
26149 120385 2
14879 157394 3
17316 151385 4
110 97882 94649
113964 181881 70591
69715 83896 21690
126304 185886 67878
12266 137373 5
9547 146671 6
15895 180688 7
127445 148010 50903
111525 178748 76767
22357 89603 33567
23668...

output:

58

result:

ok single line: '58'

Test #15:

score: 0
Accepted
time: 194ms
memory: 21684kb

input:

200000 138357
200000
97563 168748 1
121480 169972 28705
69159 97564 1
113268 173013 134879
70969 194591 2
2519 70892 131638
87476 119551 3
16847 180798 4
122445 156690 39604
2792 41948 112053
88239 119997 5
123780 172450 49760
2980 158361 6
92106 130688 7
43757 150500 8
41736 56501 41404
13 199938 9...

output:

96

result:

ok single line: '96'

Test #16:

score: 0
Accepted
time: 201ms
memory: 21760kb

input:

200000 138634
200000
13412 106507 1
6982 122713 2
33172 186418 3
17032 178639 4
20457 56783 91166
14032 198801 5
29425 120403 6
62971 184849 7
17068 148479 8
31538 108431 9
6929 156115 10
70409 130854 11
9201 191652 12
12328 110692 13
12547 175480 14
123064 195036 125919
38727 62104 40520
15935 9734...

output:

134

result:

ok single line: '134'

Test #17:

score: 0
Accepted
time: 190ms
memory: 21676kb

input:

200000 138523
200000
8801 43594 65779
30315 121343 1
32563 175315 2
34714 137247 3
1852 192103 4
9116 154124 5
55686 122859 6
46819 188532 7
104198 113773 72996
83301 198496 8
128220 146500 33468
106237 182849 80445
84987 193777 9
15695 124485 10
48466 49014 134680
99332 162256 11
117173 138810 4304...

output:

101

result:

ok single line: '101'

Test #18:

score: 0
Accepted
time: 197ms
memory: 21636kb

input:

200000 138560
200000
99444 177251 1
33815 99506 1
52545 85509 53455
27157 161177 2
65705 154853 3
31212 168659 4
17113 118124 5
75676 140707 6
73188 89966 90184
98502 189745 7
2949 98594 7
79686 90129 71434
32433 196739 8
25736 197856 9
30848 175414 10
99679 150718 11
92322 99663 11
31406 189873 12
...

output:

87

result:

ok single line: '87'

Test #19:

score: 0
Accepted
time: 195ms
memory: 21756kb

input:

200000 138852
200000
11088 174943 1
12490 88090 14251
121544 196026 24371
79012 172182 2
33828 147311 3
126591 145318 29144
84154 115239 4
88439 187456 5
86924 136004 6
70559 112099 7
144534 187192 128946
27119 40875 111742
91959 137440 8
86124 117105 9
54370 147502 10
36092 190371 11
3317 154073 12...

output:

71

result:

ok single line: '71'

Test #20:

score: 0
Accepted
time: 194ms
memory: 21568kb

input:

200000 137957
200000
53535 192730 1
27942 194948 2
30205 197630 3
54587 147476 4
123389 174530 32004
19754 177050 5
30020 158862 6
46421 185234 7
729 195603 8
84317 176615 9
12712 195897 10
37278 57234 1064
54240 75156 18428
71856 139775 11
94302 145330 12
57797 168665 13
7696 184921 14
12057 104581...

output:

56

result:

ok single line: '56'

Test #21:

score: 0
Accepted
time: 191ms
memory: 21688kb

input:

200000 138227
200000
89282 104119 1
104136 119488 1
6632 180271 2
4201 96962 93748
42881 185441 3
20881 110268 4
35209 173215 5
7598 154986 6
2597 83441 82065
49272 190222 7
45798 150306 8
70269 144641 9
10230 133853 10
3383 167583 11
98257 99825 12
4941 98271 12
152906 160304 134993
99661 135837 12...

output:

67

result:

ok single line: '67'

Test #22:

score: 0
Accepted
time: 199ms
memory: 21688kb

input:

200000 138439
200000
36076 177181 1
55482 75892 102234
82569 157515 2
11817 31513 84694
139420 184455 17373
20271 98425 63898
143090 144571 25984
66036 195796 3
96739 122860 4
29059 140142 5
81150 115500 6
113724 149712 104187
166370 187909 86676
3416 133851 7
44819 185412 8
13776 137464 9
10359 163...

output:

22

result:

ok single line: '22'

Test #23:

score: 0
Accepted
time: 199ms
memory: 21604kb

input:

200000 138634
200000
11325 134620 1
4072 196810 2
2277 82475 127183
87267 174551 3
134053 175644 24122
802 164662 4
4531 192715 5
2284 195173 6
22093 169841 7
14400 79418 137320
102963 137713 71466
17715 190193 8
20134 190276 9
13469 196737 10
51882 54778 100070
8896 131235 11
41325 137973 12
14249 ...

output:

125

result:

ok single line: '125'

Test #24:

score: 0
Accepted
time: 72ms
memory: 20440kb

input:

256 200000
200000
2 256 1
2 256 2
1 255 3
2 256 4
1 256 5
1 256 6
1 255 7
1 256 8
2 256 9
1 256 10
2 256 11
1 255 12
1 256 13
2 256 14
1 256 15
2 256 16
1 255 17
2 256 18
2 256 19
1 256 20
2 256 21
2 256 22
1 256 23
2 256 24
1 256 25
2 256 26
1 255 27
2 256 28
1 256 29
1 256 30
1 256 31
1 256 32
1 2...

output:

254

result:

ok single line: '254'

Test #25:

score: 0
Accepted
time: 76ms
memory: 20244kb

input:

1024 200000
200000
1 1023 1
1 1024 2
1 1024 3
1 1024 4
2 1024 5
1 1024 6
1 1023 7
2 1024 8
2 1024 9
2 1024 10
1 1024 11
1 1024 12
2 1024 13
1 1024 14
2 1024 15
1 1024 16
1 1024 17
2 1024 18
1 1024 19
1 1023 20
1 1024 21
1 1024 22
1 1024 23
1 1023 24
1 1024 25
1 1024 26
1 1023 27
1 1024 28
1 1024 29
...

output:

1022

result:

ok single line: '1022'

Test #26:

score: 0
Accepted
time: 77ms
memory: 21144kb

input:

65536 200000
200000
2 65536 1
1 65535 2
1 65535 3
1 65536 4
1 65536 5
2 65536 6
1 65535 7
1 65535 8
1 65536 9
1 65535 10
1 65536 11
1 65536 12
1 65536 13
2 65536 14
2 65536 15
1 65535 16
1 65536 17
1 65535 18
1 65536 19
1 65535 20
1 65536 21
1 65536 22
2 65536 23
1 65535 24
2 65536 25
1 65535 26
1 6...

output:

65534

result:

ok single line: '65534'

Test #27:

score: 0
Accepted
time: 70ms
memory: 20460kb

input:

200000 200000
200000
1 199999 1
2 200000 2
1 199999 3
1 200000 4
2 200000 5
2 200000 6
1 199999 7
1 200000 8
1 200000 9
1 200000 10
1 200000 11
1 200000 12
2 200000 13
1 200000 14
1 200000 15
1 200000 16
1 200000 17
1 199999 18
1 199999 19
1 199999 20
1 200000 21
1 200000 22
1 199999 23
1 200000 24
...

output:

199998

result:

ok single line: '199998'

Test #28:

score: 0
Accepted
time: 63ms
memory: 20212kb

input:

1024 199653
200000
1 1 1
5 5 2
9 9 2
13 13 1
16 16 2
20 20 2
24 24 1
28 28 1
30 30 1
34 34 2
36 36 2
38 38 1
40 40 1
44 44 2
48 48 1
50 50 2
53 53 2
55 55 1
59 59 1
62 62 2
65 65 1
67 67 1
70 70 1
72 72 1
74 74 1
78 78 1
82 82 1
86 86 2
88 88 2
90 90 2
92 92 1
95 95 1
97 97 2
99 99 1
101 101 2
104 1...

output:

189

result:

ok single line: '189'

Test #29:

score: 0
Accepted
time: 59ms
memory: 20332kb

input:

200000 133429
200000
1 1 1
4 4 1
7 7 1
10 10 1
14 14 1
16 16 2
20 20 2
22 22 2
26 26 1
29 29 1
31 31 1
35 35 1
37 37 2
40 40 1
43 43 1
46 46 2
49 49 2
53 53 2
55 55 2
58 58 2
60 60 2
64 64 2
68 68 2
72 72 2
76 76 2
80 80 2
84 84 1
87 87 2
89 89 2
92 92 1
96 96 1
98 98 1
102 102 2
106 106 1
108 108 2...

output:

33146

result:

ok single line: '33146'

Test #30:

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

input:

1024 100000
200000
1 385 1
386 1024 1
1 456 2
457 1024 2
1 301 3
302 1024 3
1 604 4
605 1024 4
1 566 5
567 1024 5
1 461 6
462 1024 6
1 701 7
702 1024 7
1 13 8
14 1024 8
1 208 9
209 1024 9
1 562 10
563 1024 10
1 583 11
584 1024 11
1 346 12
347 1024 12
1 605 13
606 1024 13
1 590 14
591 1024 14
1 471 1...

output:

1024

result:

ok single line: '1024'

Test #31:

score: 0
Accepted
time: 110ms
memory: 16928kb

input:

200000 100000
200000
1 163795 1
163796 200000 1
1 45806 2
45807 200000 2
1 44343 3
44344 200000 3
1 103188 4
103189 200000 4
1 120067 5
120068 200000 5
1 102496 6
102497 200000 6
1 158878 7
158879 200000 7
1 59934 8
59935 200000 8
1 59012 9
59013 200000 9
1 156039 10
156040 200000 10
1 187280 11
187...

output:

200000

result:

ok single line: '200000'

Test #32:

score: 0
Accepted
time: 74ms
memory: 20188kb

input:

200000 200000
200000
2 199999 1
2 199999 2
2 199999 3
2 199999 4
2 199999 5
2 199999 6
2 199999 7
2 199999 8
2 199999 9
2 199999 10
2 199999 11
2 199999 12
2 199999 13
2 199999 14
2 199999 15
2 199999 16
2 199999 17
2 199999 18
2 199999 19
2 199999 20
2 199999 21
2 199999 22
2 199999 23
2 199999 24
...

output:

199998

result:

ok single line: '199998'

Test #33:

score: 0
Accepted
time: 77ms
memory: 20524kb

input:

200000 200000
200000
2 199999 1
1 200000 2
2 199999 3
1 200000 4
2 199999 5
1 200000 6
2 199999 7
1 200000 8
2 199999 9
1 200000 10
2 199999 11
1 200000 12
2 199999 13
1 200000 14
2 199999 15
1 200000 16
2 199999 17
1 200000 18
2 199999 19
1 200000 20
2 199999 21
1 200000 22
2 199999 23
1 200000 24
...

output:

199998

result:

ok single line: '199998'