QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#560123 | #8672. 排队 | Sakuyamaid | 15 | 185ms | 48536kb | C++20 | 7.3kb | 2024-09-12 13:00:27 | 2024-09-12 13:00:27 |
Judging History
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);
}
}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
Wrong Answer
Test #1:
score: 10
Accepted
time: 3ms
memory: 13868kb
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
Wrong Answer
time: 3ms
memory: 12500kb
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:
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ...
result:
wrong answer 593rd numbers differ - expected: '10', found: '9'
Subtask #2:
score: 15
Accepted
Test #12:
score: 15
Accepted
time: 143ms
memory: 44544kb
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:
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 ...
result:
ok 200000 numbers
Test #13:
score: 15
Accepted
time: 142ms
memory: 48536kb
input:
200000 200000 5 45 27 99 7 23 51 88 16 62 10 24 16 80 43 70 12 45 35 55 6 99 77 91 40 82 66 99 30 47 18 80 9 36 4 12 26 51 37 64 39 52 2 11 2 69 57 81 15 98 8 36 19 27 32 34 35 97 22 23 15 89 53 77 2 89 25 55 25 90 4 91 13 77 37 65 67 89 8 52 20 58 10 18 31 81 35 59 41 56 71 74 18 61 56 77 51 74 40 ...
output:
101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 0 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 101 10...
result:
ok 200000 numbers
Test #14:
score: 15
Accepted
time: 150ms
memory: 45752kb
input:
200000 200000 193 894 142 229 346 553 197 496 389 718 370 600 650 853 476 695 764 767 220 571 238 714 516 700 137 692 1 293 835 962 34 536 208 482 148 225 377 804 75 864 277 925 278 864 296 647 390 757 179 283 338 602 571 746 447 852 315 365 7 390 634 689 76 239 16 60 244 388 385 822 451 836 301 373...
output:
1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 961 999 1001 1001 1001 1001 1001 1001 981 1001 1001 1001 1001 1001 1001 1001 966 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001 1001...
result:
ok 200000 numbers
Test #15:
score: 15
Accepted
time: 149ms
memory: 36116kb
input:
200000 200000 3145 7698 6037 6154 6483 6707 6834 7442 7373 9621 5166 8045 7346 8938 2235 5518 2240 4134 586 3188 3845 8054 1258 5380 2409 2631 3360 5706 19 2771 1925 9642 6687 8264 4305 8055 2844 5474 2282 7810 1738 4706 1462 7466 17 6282 2481 6022 2363 2987 3633 4157 1460 2634 4866 8159 3154 5079 2...
output:
9965 10001 0 10001 10001 10001 9991 10001 4831 9935 5274 10001 10001 2 10001 10001 10001 10001 9991 10001 10001 10001 10001 9935 9994 10001 9742 10001 10001 0 9982 10001 10001 10001 10001 10001 80 0 9991 9763 8 10001 9975 9939 10001 10001 9092 9983 9333 10001 10001 10001 10001 10001 10001 10001 9965...
result:
ok 200000 numbers
Test #16:
score: 15
Accepted
time: 121ms
memory: 36120kb
input:
200000 200000 15540 44932 12196 33126 776 23774 35673 42863 31231 44618 16521 19781 8467 9747 5319 42216 13940 21955 3389 6981 22 11576 15248 17307 5734 35942 12762 45217 30349 47977 8869 11242 11199 25942 3415 10196 20104 40771 8813 28517 29726 34188 13420 13731 17526 30474 1033 44930 3143 10541 46...
output:
8 31 33781 8 161 3 618 14580 3 25947 1415 455 2 147 16877 21598 539 56 7425 6686 4 393 4 4 4378 176 24 1407 837 19 14 7146 7 19626 21422 9 20472 0 200 3514 2 380 35942 35129 1 216 3 312 1200 2519 4046 9 1734 1318 21862 3361 27414 52 38201 2303 635 235 1 17 271 24468 29 1029 1071 38200 10968 95 4 125...
result:
ok 200000 numbers
Test #17:
score: 15
Accepted
time: 132ms
memory: 47124kb
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:
74058 156458 175945 88572 145372 79026 163392 139232 188241 158454 17719 20452 171150 171343 104047 159458 132045 70328 136937 64711 174467 69614 125002 131739 81388 166709 80139 138489 34431 142820 179669 125831 148484 115982 184021 189596 73421 151270 194210 134276 117448 129846 127920 160607 1132...
result:
ok 200000 numbers
Test #18:
score: 15
Accepted
time: 146ms
memory: 47052kb
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:
173310 165951 120854 142558 87420 163018 160623 76341 172338 95167 169845 31220 168100 132276 165092 84047 128575 138423 171800 154331 137251 163376 79848 167392 43722 41974 133487 110272 168461 91407 103766 57088 165360 154903 110464 80792 144277 102908 146051 175704 77052 168422 56979 126413 14964...
result:
ok 200000 numbers
Test #19:
score: 15
Accepted
time: 152ms
memory: 46672kb
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:
131384 192629 61130 80247 87887 198740 163105 103211 176599 77117 195385 125105 27678 146598 146076 171154 143664 106375 184677 176668 63515 47861 66512 94607 61773 118863 110829 90228 162033 193193 118985 114311 63857 156350 94535 157429 67223 146494 96304 188983 139817 196687 121473 115649 160519 ...
result:
ok 200000 numbers
Test #20:
score: 15
Accepted
time: 152ms
memory: 46216kb
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:
191039 169762 165539 174400 68195 177129 154654 147432 156994 76044 194413 99752 191624 151075 197252 164294 18272 88957 158459 84713 87887 43439 179674 131694 123135 59410 106882 159392 139714 64645 69698 100948 140917 103251 45494 170482 166885 104101 194216 145914 120315 76168 77653 141867 198409...
result:
ok 200000 numbers
Test #21:
score: 15
Accepted
time: 104ms
memory: 35612kb
input:
200000 200000 17611 69131 59430 76978 15340 23731 45422 61357 24684 32905 12111 30945 3173 53122 1908 18775 21868 25563 43076 69772 23316 73134 37315 71711 16622 29769 5311 27384 7573 9838 45306 81042 21408 85530 32497 55253 12816 72989 13973 55180 2256 48643 39562 81719 47954 61844 8166 64533 5302 ...
output:
1 2 6 0 2 0 0 0 3 7 1 2 0 0 2 10 1 0 0 1 13 0 2 2 0 4 0 1 7 0 4 14 1 1 0 2 0 0 0 0 5 0 14 4 0 2 14 0 2 0 0 2 1 0 2 1 0 8 10 0 0 8 3 0 10 4 1 1 0 0 13 3 0 4 0 1 1 2 0 1 8 4 1 0 0 5 2 8 0 0 0 1 1 0 0 0 4 9 9 7 2 0 2 13 3 0 0 2 0 0 0 1 0 5 10 5 13 1 0 7 10 1 2 3 0 0 1 5 1 5 0 0 1 0 1 0 1 0 1 7 4 1 0 3 ...
result:
ok 200000 numbers
Subtask #3:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 180ms
memory: 47120kb
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:
19140 39287 14840 58654 15426 4999 26338 93249 2826 78084 64069 55480 2565 15172 24866 57626 35886 51334 67552 44939 27730 24780 54501 26902 73199 7553 3835 41740 67888 104575 43522 3766 13006 31659 17263 85349 16595 28680 64011 56457 23855 47819 22751 86122 37679 44827 88809 36305 15842 33727 10005...
result:
wrong answer 1st numbers differ - expected: '19141', found: '19140'
Subtask #4:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 185ms
memory: 44948kb
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 21389 65744 47217 62291 29290 146310 136621 165311 81581 25123 120261 104923 12517 90913 31779 50071 15585 1517 106445 92327 71503 16694 4845 38212 34900 133280 98867 697 26263 6631 173459 61315 71680 15562 112191 125787 15304 41840 30379 24107 17435 10898 115177 22279 37581 101775 120168 1264...
result:
wrong answer 2nd numbers differ - expected: '21392', found: '21389'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%