QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#559560 | #8672. 排队 | Sakuyamaid | 0 | 184ms | 43488kb | C++20 | 7.1kb | 2024-09-11 23:40:36 | 2024-09-11 23:40:36 |
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];
auto ll = queryl(1, 1, n, now, max(i - 1, 1), L);
auto rr = queryr(1, 1, n, now, max(i - 1, 1), R);
// cout << ll << " " << rr << " " << max(i - 1, 1) << "\n";
if(ll != -1 && rr != -1){
if(l[i] == 0 && i != now)rr += 1;
update(1, 1, n, ll, rr, 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: 3ms
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: 5ms
memory: 12368kb
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:
794 302 2370 613 152 2172 3360 3286 480 176 575 386 3940 418 1344 994 2053 2287 2789 1750 1272 137 1822 2466 386 1292 65 54 1823 3381 3478 666 1634 652 1053 2312 60 686 3017 1007 149 2672 895 2078 2610 56 2703 864 1481 1240 767 608 1266 1056 930 2400 1276 289 1988 900 2398 2773 1133 1129 1872 3033 1...
result:
wrong answer 1st numbers differ - expected: '11', found: '794'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 125ms
memory: 42596kb
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:
124434 148218 119412 25010 33581 3855 135041 83061 137073 66422 169712 87082 13009 131900 172184 143449 15947 77662 62643 39576 8928 34758 39735 115019 4630 7474 93331 87514 58263 56470 60864 87418 123059 90141 36658 148840 145723 75290 168373 99045 105070 66532 67818 123882 1803 77848 170304 126927...
result:
wrong answer 1st numbers differ - expected: '11', found: '124434'
Subtask #3:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 163ms
memory: 42980kb
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:
20249 41549 15729 62082 16345 5294 27865 98653 2986 82599 67792 58688 2721 16040 26273 60953 37953 54295 71492 47553 29315 26218 57661 28470 77471 7990 4084 44166 71815 110616 46067 3996 13737 33485 18277 90300 17582 30356 67700 59712 25247 50614 24036 91120 39863 47404 93955 38437 16767 35704 10587...
result:
wrong answer 1st numbers differ - expected: '19141', found: '20249'
Subtask #4:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 184ms
memory: 43488kb
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%