QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#560130#8672. 排队Sakuyamaid15 220ms49076kbC++207.4kb2024-09-12 13:21:302024-09-12 13:21:30

Judging History

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

  • [2024-09-12 13:21:30]
  • 评测
  • 测评结果:15
  • 用时:220ms
  • 内存:49076kb
  • [2024-09-12 13:21:30]
  • 提交

answer

// buxiangwanla
// 你紫名觉得是我的锅,那就是我的锅,为什么你知道吗?因为紫名说的话,就像是一个癌症晚期患者说的话一样。
// 他都已经这样了,你为什么不顺从他呢?你总要给人最后一段时间一个好的回忆吧,最后的时光里。
// 因为紫名这个段位很尴尬,紫名橙名再往上一点,grandmaster,可能说,欸,有点实力,能操作一下。
// 紫名往下,绿名,蓝名,啊,人家是纯属玩游戏的,因为太垃圾了,自己也知道自己没什么实力。
// 但紫名,上不去下不来的这个段位,他觉得,蓝名的人不配跟他一起玩儿,对吧?蓝名是最垃圾的。
// 但是呢他想上去,他又上不去,所以这个分段是最尴尬的,没办法,卡在这里了。
// 想操作,又操作不起来,掉下去吧,他又觉得不值得,对吧,我好不容易从蓝名打到紫名了,我为什么还要掉下去呢?
// 这个人说优越狗越说越起劲,为什么他会这么说?因为他是紫名。
// 他觉得你比我段位高,你说的任何话都是优越,我并不管你说的有没有道理。
// 我紫名,我最猛,我WF2017我上我能夺冠,那打比赛全是sb。你比我段位高你说话就是放屁,这就是这种人的想法。但是呢,他的想法是对的,为什么呢?
// 因为他癌症晚期。没办法,我同意,对不起,我优越了。可能是我膨胀了,不好意思啊,我膨胀了。我紫名是没操作,难道我就看不懂谁背锅吗?
// 不是,如果你看得懂的话,就不会在这里抬杠了,对吧。

// If you Blue Name think it's my fault, it's my fault. Do you know why? Because what Blue Name says is like something a terminal cancer patient would say.
// He's already like that. Why don't you just go along with it? You always have to give someone a good memory for the last period of time, right? In the last time.
// Because the blue name of this rating is very awkward, blue name purple name a little further up, master, may say, hey, a little strength, can operate a little.
// Blue name down, green name, ah, people are purely playing the game, because it is too trash, they also know that they do not have much strength.
// But the blue name, can't go up or down in this rating, he thinks, the green name of the person does not deserve to play with him, right? Green name is the most trash.
// But he wants to go up, he can not go up, so this rating is the most embarrassing, no way, stuck here.
// I want to solve, but I can not solve the problems, fall down, he also think it is not worth it, right, it is not easy for me to fight from the green name to the blue name, why do I have to fall down?
// This person said superior dog the more he said the more energized, why would he say so? Because he's blue.
// He thinks you are higher than me, anything you say is superior, I don't care if what you say makes sense or not.
// I'm not sure if there's any truth in what you're saying, but I'm not sure if there's any truth in what you're saying, and I'm not sure if there's any truth in what you're saying, and I'm not sure if there's any truth in what you're saying. But then, his idea is right, why?
// Because he has terminal cancer. No way, I agree. I'm sorry, I'm superior. Maybe I'm bloated. I'm sorry, I'm bloated. My blue name is no operation. Can't I see who's taking the fall?
// No, if you could see it, you wouldn't be here carrying the can, would you.
// 
#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long ULL;
using LL = long long;

constexpr int N = 1e6 + 5, mod = 998244353;
constexpr double eps = 1e-8;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")

#define fi first
#define se second
#define int long long
#define lowbit(x) (x & (-x))
#define PII pair<int, int>
#define mid ((l + r) >> 1)

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int ksm(int a, int b){
    a %= mod;
    int res = 1;
    while(b){
        if(b & 1)res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int n, m;
int a[N];
int l[N], r[N], q;
int ans[N];
struct Node{
    int l, r, id;
}qe[N];
vector<Node>Q[N];
int tag[N << 2], maxn[N << 2], minn[N << 2];

void pushdown(int u, int l, int r){
    if(tag[u]){
        int c = tag[u];
        tag[u << 1] += c;
        tag[u << 1 | 1] += c;
        maxn[u << 1] += c;
        maxn[u << 1 | 1] += c;
        minn[u << 1] += c;
        minn[u << 1 | 1] += c;
        tag[u] = 0;
    }
}

int pushupmax(int res1, int res2){
    return max(res1, res2);
}

int pushupmin(int res1, int res2){
    return min(res1, res2);
}

void update(int u, int l, int r, int x, int y, int z){
    if(x <= l && y >= r){
        tag[u] += z;
        maxn[u] += z;
        minn[u] += z;
        return;
    }
    pushdown(u, l, r);
    if(x <= mid)update(u << 1, l, mid, x, y, z);
    if(y > mid)update(u << 1 | 1, mid + 1, r, x, y, z);
    maxn[u] = pushupmax(maxn[u << 1], maxn[u << 1 | 1]);
    minn[u] = pushupmin(minn[u << 1], minn[u << 1 | 1]);
}

int queryl(int u, int l, int r, int x, int y, int p){
    if(x <= l && y >= r){
        if(minn[u] > p)return -1;
        if(l == r)return l;
    }
    pushdown(u, l, r);
    if(x <= mid){
        int res = queryl(u << 1, l, mid, x, y, p);
        if(res != -1)return res;
    }
    if(x <= mid){
        return queryl(u << 1 | 1, mid + 1, r, x, y, p);
    }
    return -1;
}

int queryr(int u, int l, int r, int x, int y, int p){
    if(x <= l && y >= r){
        if(maxn[u] < p)return -1;
        if(l == r)return l;
    }
    pushdown(u, l, r);
    if(y > mid){
        int res = queryr(u << 1 | 1, mid + 1, r, x, y, p);
        if(res != -1)return res;
    }
    if(x <= mid){
        return queryr(u << 1, l, mid, x, y, p);
    }
    return -1;
}

int query(int u, int l, int r, int p){
    if(l == r){
        return maxn[u];
    }
    pushdown(u, l, r);
    if(p <= mid)return query(u << 1, l, mid, p);
    else return query(u << 1 | 1, mid + 1, r, p);
}

void Sakuya()
{
    cin >> n >> q;
    for(int i = 1; i <= n; ++ i)cin >> l[i] >> r[i];
    
    for(int i = 1; i <= q; ++ i){
        cin >> qe[i].l >> qe[i].r, qe[i].id = i;
        Q[qe[i].r].emplace_back(qe[i].l, i, 0);
    }

    sort(qe + 1, qe + 1 + q, [&](Node a, Node b){return a.l < b.l;});

    int now = qe[1].l;
    // now = 1;
    for(int i = now; i <= n; ++ i){
        auto L = l[i], R = r[i];
        if(i - 1 >= now){
            auto ll = queryl(1, 1, n, now, i - 1, R);
            auto rr = queryr(1, 1, n, now, i - 1, L);
            if(ll != -1 && rr != -1){
                update(1, 1, n, ll, rr, 1);
            }
            if(l[i] == 0)update(1, 1, n, i, i, 1);
        }else {
            if(l[i] == 0)update(1, 1, n, i, i, 1);
        }
        if(Q[i].size()){
            for(auto [LL, id, _] : Q[i]){
                ans[id] = query(1, 1, n, LL);
            }
        }
    }
    for(int i = 1; i <= q; ++ i){
        cout << ans[i] << "\n";
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    // int T;
    // for (cin >> T; T -- ; )
        Sakuya();

}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 10
Accepted
time: 0ms
memory: 13924kb

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: 0
Runtime Error

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:


result:


Subtask #2:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

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:


result:


Subtask #3:

score: 0
Runtime Error

Test #22:

score: 0
Runtime Error

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:


result:


Subtask #4:

score: 15
Accepted

Test #32:

score: 15
Accepted
time: 207ms
memory: 47100kb

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
47218
62293
29293
146310
136621
165312
81582
25124
120262
104926
12518
90915
31784
50073
15588
1517
106447
92329
71506
16694
4846
38213
34902
133281
98867
697
26263
6631
173459
61316
71682
15564
112191
125788
15305
41840
30379
24107
17435
10898
115177
22279
37582
101778
120170
1264...

result:

ok 200000 numbers

Test #33:

score: 15
Accepted
time: 215ms
memory: 49076kb

input:

200000 200000
5 200000
0 200000
1 200000
0 200000
2 200000
1 200000
0 200000
3 200000
4 200000
1 200000
0 200000
2 200000
1 200000
0 200000
0 200000
5 200000
2 200000
0 200000
2 200000
2 200000
0 200000
1 200000
3 200000
4 200000
2 200000
0 200000
5 200000
0 200000
3 200000
0 200000
0 200000
5 20000...

output:

51850
27495
33433
90638
103054
58851
115355
44294
80395
72594
155250
20604
154366
112939
168447
70437
134688
175930
112777
43168
73760
136485
95405
115772
19580
14448
85020
8135
266
66591
24765
14783
101583
182811
27593
75020
64180
50889
69744
140901
99500
62001
74634
142631
93413
188391
25666
29627...

result:

ok 200000 numbers

Test #34:

score: 15
Accepted
time: 209ms
memory: 47324kb

input:

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

output:

48539
120803
28813
145711
29729
172683
112151
52277
31739
73432
63297
64022
176699
103343
145926
110637
5216
25387
86738
39373
77641
3608
134147
26930
117814
50832
9240
59137
73006
34370
34497
804
96016
101388
3489
30001
85307
17852
1324
32486
37351
12503
28321
42856
196324
95124
119392
87948
28069
...

result:

ok 200000 numbers

Test #35:

score: 15
Accepted
time: 204ms
memory: 43624kb

input:

200000 200000
45 200000
27 200000
7 200000
51 200000
16 200000
10 200000
16 200000
43 200000
12 200000
35 200000
6 200000
77 200000
40 200000
66 200000
30 200000
18 200000
36 200000
12 200000
26 200000
37 200000
39 200000
11 200000
69 200000
57 200000
15 200000
8 200000
19 200000
32 200000
35 200000...

output:

102146
138864
3922
35890
61622
45382
45112
14900
58606
39462
173762
102549
8848
81805
48479
48103
10353
63948
139153
34744
24441
35639
58427
40153
41974
28423
106874
11420
118809
141816
59608
59417
25106
134727
11556
40866
27752
61000
52123
94606
325
144695
24421
115649
156435
132658
25786
136006
18...

result:

ok 200000 numbers

Test #36:

score: 15
Accepted
time: 220ms
memory: 45756kb

input:

200000 200000
894 200000
142 200000
346 200000
496 200000
389 200000
600 200000
650 200000
476 200000
767 200000
220 200000
238 200000
516 200000
137 200000
1 200000
835 200000
34 200000
208 200000
225 200000
377 200000
75 200000
277 200000
278 200000
647 200000
390 200000
179 200000
602 200000
571 ...

output:

82980
71975
66684
28250
111297
44819
114569
54121
107328
25452
72738
53632
23692
426
71363
73241
154868
34365
20278
17775
146745
22972
136874
69984
53
79587
2967
124150
52120
87623
89603
4325
87876
13984
119053
27551
69825
112363
84048
157846
1462
94224
79643
115628
117698
116223
38012
32665
94002
1...

result:

ok 200000 numbers

Test #37:

score: 15
Accepted
time: 162ms
memory: 44560kb

input:

200000 200000
30 200000
9 200000
18 200000
24 200000
68 200000
54 200000
26 200000
3 200000
42 200000
32 200000
27 200000
58 200000
1 200000
34 200000
16 200000
61 200000
11 200000
25 200000
69 200000
48 200000
1 200000
11 200000
51 200000
46 200000
45 200000
48 200000
8 200000
11 200000
76 200000
1...

output:

173724
167565
196183
155627
73842
112798
182774
198559
148707
78823
124508
189149
139326
167284
179483
145557
81468
183248
195819
198503
179022
158694
167743
30007
115871
163056
159742
39661
110436
112768
148610
172927
108963
141742
144742
195300
136697
158981
169064
113954
164065
191476
87872
11760...

result:

ok 200000 numbers

Test #38:

score: 15
Accepted
time: 178ms
memory: 48032kb

input:

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

output:

46615
181434
182190
170634
93896
160383
177806
162444
168792
138030
132992
146565
174737
175152
50188
136539
105800
168041
179972
82742
181959
171407
173501
132587
137393
55914
157218
61659
132609
192152
167976
117558
60445
119612
112065
109544
154984
108960
161879
140516
153475
78686
127811
108796
...

result:

ok 200000 numbers

Test #39:

score: 15
Accepted
time: 179ms
memory: 42544kb

input:

200000 200000
200 200000
418 200000
690 200000
193 200000
63 200000
799 200000
474 200000
40 200000
287 200000
38 200000
204 200000
334 200000
258 200000
262 200000
269 200000
368 200000
167 200000
30 200000
51 200000
55 200000
119 200000
523 200000
33 200000
896 200000
253 200000
674 200000
119 200...

output:

171189
85389
126329
140440
183837
83618
89897
140242
183271
155531
156556
101126
70897
129804
140582
38794
150678
129225
97071
167132
123699
102800
162069
161274
162407
179233
150750
147270
150942
171716
178973
170764
152580
176935
138712
165104
157524
7651
105384
116173
174996
159737
138067
119161
...

result:

ok 200000 numbers

Test #40:

score: 15
Accepted
time: 159ms
memory: 35268kb

input:

200000 200000
611 200000
1167 200000
3159 200000
3415 200000
2254 200000
697 200000
6942 200000
23 200000
1856 200000
894 200000
6650 200000
3813 200000
5825 200000
5844 200000
5534 200000
6993 200000
3021 200000
515 200000
1584 200000
2031 200000
265 200000
8912 200000
6889 200000
6934 200000
833 2...

output:

73994
144591
49265
71224
136162
94664
159060
157355
118335
31810
103232
94713
103259
155339
60542
143894
121148
83887
112143
121172
58706
128573
148964
30102
37612
48511
115410
139260
109
43908
122649
126684
199
98137
22165
80600
2
77835
100163
132242
113078
105702
88160
62364
9
91895
58316
158056
1...

result:

ok 200000 numbers

Test #41:

score: 15
Accepted
time: 119ms
memory: 36128kb

input:

200000 200000
3480 200000
36579 200000
10485 200000
18356 200000
20788 200000
3352 200000
4565 200000
33362 200000
6894 200000
25647 200000
5915 200000
19265 200000
3530 200000
26535 200000
18506 200000
18191 200000
35793 200000
7442 200000
993 200000
14550 200000
13606 200000
5553 200000
12284 2000...

output:

5275
1880
872
857
82
152
7419
496
461
371
2714
1207
660
1744
219
63
17
3346
5677
461
1231
196
2250
97
3770
214
986
189
180
584
2666
0
821
107
839
8
223
90
476
71
867
107
6918
4760
4033
454
3138
1159
6072
4693
56
191
186
245
474
104
377
3627
141
3367
3835
1005
2433
223
6480
2854
29
213
120
6433
57
11...

result:

ok 200000 numbers

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%