QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416292#8672. 排队BreakPlus0 125ms46896kbC++141.3kb2024-05-21 18:56:102024-05-21 18:56:11

Judging History

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

  • [2024-05-21 18:56:11]
  • 评测
  • 测评结果:0
  • 用时:125ms
  • 内存:46896kb
  • [2024-05-21 18:56:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back 
const ll N = 1000000;
inline ll read(){ ll x; scanf("%lld",&x); return x; }
ll n,q,l[N+5],r[N+5],ans[N+5]; 
vector<P>vec[N+5];
inline ll lowbit(ll x){ return x&(-x); } 
ll c[N+5];
void update(ll x,ll w){
	for(; x <= n; x += x&-x) c[x] += w;
}
ll query(ll x){
	ll ans = 0;
	for(; x; x -= x&-x) ans += c[x]; return ans;
}
int main(){
	n=read(), q=read();
	for(ll i=1;i<=n;i++) l[i]=read(), r[i]=read();
	for(ll i=1;i<=q;i++){
		ll L=read(), R=read();
		vec[R].pb(L, i);
	}
	for(ll i=1;i<=n;i++){
		ll sum = query(i);
		ll ans1 = 0, sum1 = 0;
		for(ll j=19; j>=0; j--){
			if(ans1 + (1<<j) < i){
				if(sum1 + c[ans1 + (1<<j)] < l[i]) {
					sum1 += c[ans1 + (1<<j)];
					ans1 += (1<<j);
				}
			}
		}
		ll ans2 = 0, sum2 = 0;
		for(ll j=19; j>=0; j--){
			if(ans2 + (1<<j) < i){
				if(sum2 + c[ans2 + (1<<j)] <= r[i]) {
					sum2 += c[ans2 + (1<<j)];
					ans2 += (1<<j);
				}
			}
		}
		
		update(ans1+1, 1); update(ans2+1, -1);
		if(l[i] == 0) update(i, 1), update(i+1, -1); 
		for(auto p: vec[i]){
			ans[p.se] = query(p.fi);
		}
	}
	for(ll i=1;i<=q;i++) printf("%lld\n", ans[i]);
} 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 4ms
memory: 32652kb

input:

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

output:

1
3
1

result:

ok 3 number(s): "1 3 1"

Test #2:

score: -10
Wrong Answer
time: 7ms
memory: 34804kb

input:

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

output:

48
1
11
1
0
11
94
42
11
0
8
0
44
11
11
0
22
40
44
11
11
1
63
34
1
40
0
11
56
57
55
11
0
11
0
22
0
72
33
0
0
23
12
80
22
5
22
33
42
22
0
1
11
11
12
22
12
9
22
0
23
56
11
12
11
34
22
34
11
65
0
11
22
23
22
44
0
0
0
22
22
25
22
12
34
12
22
56
44
12
22
33
1
11
0
11
25
11
11
0
11
0
12
0
11
57
0
11
1
12
2...

result:

wrong answer 1st numbers differ - expected: '11', found: '48'

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 108ms
memory: 46728kb

input:

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

output:

151
151
151
120
130
98
151
140
151
140
151
140
109
151
151
151
120
140
140
130
109
130
130
151
98
109
140
140
140
130
140
140
151
140
130
151
151
140
151
140
140
140
140
151
86
140
151
151
130
130
130
140
140
109
130
98
151
130
120
140
109
151
140
151
140
140
98
151
130
120
130
140
151
151
120
130
1...

result:

wrong answer 1st numbers differ - expected: '11', found: '151'

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 15
Accepted
time: 114ms
memory: 43456kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 0
0 9
0 10
0 0
0 0
0 13
0 14
0 0
0 16
0 17
0 18
0 19
0 0
0 21
0 22
0 23
0 0
0 0
0 0
0 0
0 28
0 0
0 30
0 31
0 32
0 33
0 34
0 35
0 0
0 0
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 0
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 0
0 59
0 60
0 0
0 0
...

output:

19141
39288
14841
58655
15427
4999
26338
93250
2826
78084
64070
55481
2565
15173
24866
57627
35887
51335
67552
44939
27730
24781
54502
26903
73199
7553
3836
41740
67889
104576
43522
3766
13007
31659
17264
85349
16595
28681
64012
56457
23856
47820
22752
86123
37679
44828
88810
36305
15843
33728
10005...

result:

ok 200000 numbers

Test #23:

score: 0
Accepted
time: 125ms
memory: 45472kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 0
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 0
0 27
0 28
0 29
0 30
0 0
0 32
0 33
0 34
0 35
0 36
0 0
0 0
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 0
0 58
0 59
0 60
0...

output:

168949
95410
33682
47935
82249
25613
65578
22342
60917
30684
99457
21252
87719
9508
41909
17405
96346
6219
110867
56725
71026
2090
45186
37640
26229
36720
91410
64919
7095
29903
44679
40307
100104
41603
87434
53924
53758
80720
59404
164539
38810
117092
13565
110110
38606
32273
93240
81294
10356
1504...

result:

ok 200000 numbers

Test #24:

score: 0
Accepted
time: 115ms
memory: 45448kb

input:

200000 200000
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
...

output:

69217
146306
97579
32894
129999
10418
98425
25273
33368
29464
14306
2073
112582
140228
24801
40781
52137
17338
110491
48418
54730
20451
84100
80588
2089
108163
29975
56448
14978
35560
102453
18613
30516
18699
83182
28795
25862
126187
116576
99593
36207
13935
27150
75205
66741
91089
151786
19917
2529...

result:

ok 200000 numbers

Test #25:

score: -15
Wrong Answer
time: 117ms
memory: 46896kb

input:

200000 200000
0 5
0 99
0 23
0 88
0 62
0 24
0 80
0 70
0 45
0 55
0 99
0 91
0 82
0 99
0 47
0 80
0 9
0 4
0 51
0 64
0 52
0 2
0 2
0 81
0 98
0 36
0 27
0 34
0 97
0 22
0 89
0 77
0 89
0 25
0 90
0 91
0 77
0 37
0 89
0 52
0 58
0 18
0 81
0 35
0 56
0 71
0 18
0 56
0 74
0 40
0 76
0 47
0 87
0 11
0 81
0 48
0 59
0 17
0...

output:

301
201
1
101
201
1
101
1
101
101
301
201
1
201
101
101
1
101
201
1
1
201
401
101
101
1
501
1
201
201
101
101
1
301
1
101
101
101
101
101
1
201
1
990
535
201
1
401
1
1
101
1
501
101
501
1
101
1
202
201
1
101
201
101
1
201
201
101
201
1
101
301
201
101
301
1
401
101
301
201
1
201
101
101
101
1
301
50...

result:

wrong answer 1st numbers differ - expected: '101', found: '301'

Subtask #4:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 121ms
memory: 45388kb

input:

200000 200000
0 200000
1 200000
1 200000
0 200000
0 200000
1 200000
1 200000
1 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
0 200000
0 200000
0 200000
1 200000
0 200000
0 200000
1 200000
0 200000
1 200000
1 200000
1 200000
1 200000
0 200000
0 200000
1 200000
2 200000
1 200000
2 20000...

output:

71224
21392
65746
47219
62293
29289
146310
136623
165310
81582
25122
120262
104924
12518
90916
31784
50071
15588
1517
106447
92329
71506
16692
4846
38213
34902
133279
98867
699
26263
6638
173458
61316
71680
15562
112190
125788
15305
41841
30379
24108
17435
10897
115176
22280
37582
101778
120170
1264...

result:

wrong answer 4th numbers differ - expected: '47218', found: '47219'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%