QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558052 | #8672. 排队 | robertfan | 0 | 249ms | 53460kb | C++14 | 1.9kb | 2024-09-11 13:52:27 | 2024-09-11 13:52:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int l[1000006],r[1000006],ans[1000006];
struct node{
int l,r,id;
friend bool operator<(node a,node b){
return a.l<b.l;
}
}a[1000006];
struct segnode{
int val,tag;
void plz(int u){
val+=u;
tag+=u;
}
}seg[4000006];
void push_down(int u){
seg[u<<1].plz(seg[u].tag);
seg[u<<1|1].plz(seg[u].tag);
seg[u].tag=0;
}
int query(int u,int l,int r,int val){
if(l==r)return l;
push_down(u);
int mid=l+r>>1;
if(seg[u<<1|1].val>val){
return query(u<<1|1,mid+1,r,val);
}else return query(u<<1,l,mid,val);
}
void update(int u,int l,int r,int ql,int qr){
if(ql>qr)return ;
if(ql<=l&&r<=qr){
seg[u].plz(1);
return ;
}
int mid=l+r>>1;
if(ql<=mid)update(u<<1,l,mid,ql,qr);
if(qr>mid)update(u<<1|1,mid+1,r,ql,qr);
seg[u].val=max(seg[u<<1].val,seg[u<<1|1].val);
}
vector<pair<int,int> >g[1000006];
int push(int u,int l,int r,int pos){
if(l==r){
return seg[u].val;
}
int mid=l+r>>1;
push_down(u);
if(pos<=mid)return push(u<<1,l,mid,pos);
else return push(u<<1|1,mid+1,r,pos);
}
int id[1000006];
int main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
cin>>l[i]>>r[i];
}
for(int i=1;i<=q;i++){
cin>>a[i].l>>a[i].r;
a[i].id=i;
g[a[i].r].push_back({a[i].l,a[i].id});
}
sort(a+1,a+1+q);
for(int i=1;i<=q;i++){
id[a[i].l]=i;
}
int pos=1;
for(int i=1;i<=n;i++){
while(a[pos].l==i)pos++;
update(1,1,n,query(1,1,n,r[i]),min(query(1,1,n,l[i]-1),i+1)-1);
for(pair<int,int>a:g[i]){
ans[a.second]=push(1,1,n,a.first);
}
}
for(int i=1;i<=q;i++){
cout<<ans[i]<<'\n';
}
}
/*
things to check
0.delete cerr code or use '//'
1.initallize(especially multicases)
2.int overflow/long long mle
3.if make the ans is hard , try 2-divided
4.memory &b-&a
5.function canshu position
6.the format of input
7.size enough ?
8.the name of function
9.stop copying x0->y0
*/
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 4ms
memory: 36404kb
input:
3 3 0 0 1 2 0 2 1 1 1 3 2 3
output:
1 2 1
result:
wrong answer 2nd numbers differ - expected: '3', found: '2'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 187ms
memory: 52888kb
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:
9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 ...
result:
wrong answer 1st numbers differ - expected: '11', found: '9'
Subtask #3:
score: 0
Wrong Answer
Test #22:
score: 0
Wrong Answer
time: 234ms
memory: 53356kb
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 5000 26339 93250 2827 78085 64070 55481 2566 15173 24867 57627 35887 51335 67553 44940 27731 24781 54502 26903 73200 7554 3836 41741 67889 104576 43523 3767 13007 31660 17264 85350 16596 28681 64012 56458 23856 47820 22752 86123 37680 44828 88810 36306 15843 33728 10005...
result:
wrong answer 6th numbers differ - expected: '4999', found: '5000'
Subtask #4:
score: 0
Wrong Answer
Test #32:
score: 0
Wrong Answer
time: 249ms
memory: 53460kb
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 21390 65745 47218 62292 29291 146310 136621 165312 81582 25124 120262 104924 12518 90914 31780 50072 15586 1517 106446 92328 71504 16694 4846 38213 34901 133281 98867 697 26263 6631 173459 61316 71681 15563 112191 125788 15305 41840 30379 24107 17435 10898 115177 22279 37582 101776 120169 1264...
result:
wrong answer 2nd numbers differ - expected: '21392', found: '21390'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%