QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413182 | #8672. 排队 | ANIG# | 0 | 407ms | 65624kb | C++14 | 1.7kb | 2024-05-17 09:18:29 | 2024-05-17 09:18:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5;
int n,m,l[N],r[N],rs[N],f[N];
struct node{
int l,r,laz,mx,mn;
}p[N<<2];
void upset(int x){
p[x].mx=max(p[x<<1].mx,p[x<<1|1].mx);
p[x].mn=min(p[x<<1].mn,p[x<<1|1].mn);
}
void add(int x,int sm){
p[x].laz+=sm;
p[x].mx+=sm;
p[x].mn+=sm;
}
void dnset(int x){
if(p[x].laz){
add(x<<1,p[x].laz);
add(x<<1|1,p[x].laz);
p[x].laz=0;
}
}
void add(int x,int l,int r,int sm){
if(l<=p[x].l&&r>=p[x].r){
add(x,sm);
return;
}
dnset(x);
int mid=p[x].l+p[x].r>>1;
if(l<=mid)add(x<<1,l,r,sm);
if(r>mid)add(x<<1|1,l,r,sm);
upset(x);
}
int gets(int x,int d){
if(p[x].l==p[x].r)return p[x].laz;
dnset(x);
if(d<=(p[x].l+p[x].r>>1))return gets(x<<1,d);
return gets(x<<1|1,d);
}
int gets1(int x,int k,int d){
if(p[x].l==p[x].r)return p[x].l;
dnset(x);
if(d<=(p[x].l+p[x].r>>1))return gets1(x<<1,k,d);
if(p[x<<1|1].mx>=k)return gets1(x<<1|1,k,d);
return gets1(x<<1,k,d);
}
int gets2(int x,int k){
if(p[x].l==p[x].r)return p[x].l;
dnset(x);
if(p[x<<1].mn<=k)return gets2(x<<1,k);
return gets2(x<<1|1,k);
}
void reset(int x,int l,int r){
p[x].l=l,p[x].r=r;
if(l==r)return;
int mid=l+r>>1;
reset(x<<1,l,mid);
reset(x<<1|1,mid+1,r);
}
vector<pair<int,int> >g[N];
signed main(){
cin>>n>>m;
reset(1,1,n+1);
for(int i=1;i<=n;i++)cin>>l[i]>>r[i];
for(int i=1;i<=m;i++){
int l,r;
cin>>l>>r;
g[r].push_back({l,i});
}
for(int i=1;i<=n;i++){
int a=gets2(1,r[i]),b=gets1(1,l[i],i);
for(int j=1;j<=n;j++)if(gets(1,j)<=r[i]){
a=j;
break;
}
// cout<<a<<"-"<<b<<endl;
if(a<=b)add(1,a,b,1);
for(auto c:g[i]){
rs[c.second]=gets(1,c.first);
}
}
for(int i=1;i<=m;i++)cout<<rs[i]<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 33608kb
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
Accepted
time: 407ms
memory: 34332kb
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:
ok 5000 numbers
Test #3:
score: -10
Wrong Answer
time: 379ms
memory: 35128kb
input:
5000 5000 33 36 10 96 0 89 45 59 4 38 16 26 7 83 3 45 37 78 32 57 19 58 24 88 81 87 24 68 18 38 50 78 27 92 61 98 1 13 8 63 33 55 38 76 18 43 64 72 24 93 7 34 1 38 44 72 5 36 62 71 6 72 8 53 22 93 75 78 24 69 10 38 31 99 12 100 57 67 22 65 34 44 37 88 3 48 62 84 62 79 5 68 1 18 49 57 45 64 6 38 37 3...
output:
101 101 101 101 63 101 101 101 99 100 28 86 101 92 101 101 101 101 101 101 101 101 99 101 101 101 101 92 101 101 4 101 101 101 101 101 101 74 101 101 101 101 101 101 41 101 101 51 101 101 101 101 101 101 101 100 101 101 100 101 101 101 101 101 94 101 101 101 101 101 101 46 101 99 101 101 7 101 95 10...
result:
wrong answer 3804th numbers differ - expected: '92', found: '97'
Subtask #2:
score: 0
Time Limit Exceeded
Test #12:
score: 0
Time Limit Exceeded
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
Time Limit Exceeded
Test #22:
score: 0
Time Limit Exceeded
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: 0
Wrong Answer
Test #32:
score: 15
Accepted
time: 328ms
memory: 65004kb
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
Wrong Answer
time: 325ms
memory: 65624kb
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:
wrong answer 78710th numbers differ - expected: '149749', found: '149750'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%