QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559561 | #8672. 排队 | Sakuyamaid | 0 | 208ms | 42784kb | C++20 | 7.1kb | 2024-09-11 23:43:23 | 2024-09-11 23:43:23 |
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 tr[N << 2], tag[N << 2], maxn[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;
tag[u] = 0;
}
}
int pushupmax(int res1, int res2){
return max(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;
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]);
}
int queryl(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;
}
if(x <= mid){
int res = queryl(u << 1, l, mid, x, y, p);
if(res != -1)return res;
}
if(y > 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;
}
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;
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, L);
auto rr = queryr(1, 1, n, now, i - 1, R);
if(ll != -1 && rr != -1){
update(1, 1, n, ll, rr, 1);
}
}
// cout << ll << " " << rr << " " << max(i - 1, 1) << "\n";
if(l[i] == 0)update(1, 1, n, i, i, 1);
// cout << query(1, 1, n, 1) << " " << query(1, 1, n, 2) << " " << query(1, 1, n, 3) << "\n";
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: 2ms
memory: 11816kb
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: 6ms
memory: 12292kb
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:
800 298 2346 605 152 2145 3328 3254 476 175 572 381 3900 415 1326 983 2030 2268 2763 1731 1254 135 1814 2442 377 1282 65 54 1810 3349 3445 661 1613 645 1038 2286 60 680 2986 991 147 2643 885 2100 2584 57 2675 856 1471 1231 753 602 1258 1050 924 2371 1268 287 1969 888 2375 2748 1119 1119 1851 3003 18...
result:
wrong answer 1st numbers differ - expected: '11', found: '800'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 133ms
memory: 40012kb
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:
123527 147125 118547 24808 33319 3820 134053 82439 136070 65925 168438 86428 12904 130935 170893 142397 15821 77088 62170 39270 8854 34491 39427 114184 4589 7417 92633 86857 57822 56043 60401 86761 122162 89466 36374 147741 144650 74728 167110 98315 104297 66035 67309 122980 1784 77273 169028 126004...
result:
wrong answer 1st numbers differ - expected: '11', found: '123527'
Subtask #3:
score: 0
Wrong Answer
Test #22:
score: 15
Accepted
time: 166ms
memory: 40028kb
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: 15
Accepted
time: 188ms
memory: 42784kb
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: 15
Accepted
time: 208ms
memory: 41492kb
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: 0
Wrong Answer
time: 179ms
memory: 41144kb
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:
97772 132967 3906 34419 59057 43575 43497 14412 56309 37853 166459 98216 8610 78304 46493 46203 10100 61324 133223 33477 23603 34291 56080 38465 40301 27316 102385 11175 113724 135734 57097 56989 24309 129063 11273 39341 26686 58630 49920 90679 626 138463 23517 110745 149737 127018 24769 130183 1761...
result:
wrong answer 1st numbers differ - expected: '101', found: '97772'
Subtask #4:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 160ms
memory: 41032kb
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 29293 146310 136623 165312 81582 25124 120262 104926 12518 90916 31784 50073 15588 1517 106447 92329 71506 16694 4846 38213 34902 133281 98867 699 26263 6638 173460 61316 71682 15564 112192 125788 15305 41841 30379 24108 17435 10899 115178 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%