QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#413169 | #8672. 排队 | ANIG# | 0 | 415ms | 64564kb | C++14 | 1.7kb | 2024-05-17 09:12:16 | 2024-05-17 09:12:18 |
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;
if(d<=(p[x].l+p[x].r>>1))return gets1(x<<1,k,d);
dnset(x);
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);
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);
// cout<<a<<"-"<<b<<endl;
if(a<=b)for(int j=a;j<=b;j++)add(1,j,j,1);
for(auto c:g[i]){
rs[c.second]=gets(1,c.first);
}
}
for(int i=1;i<=m;i++)cout<<rs[i]<<"\n";
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 6ms
memory: 34092kb
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: 11ms
memory: 35752kb
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: 36ms
memory: 35468kb
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
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 415ms
memory: 64564kb
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:
wrong answer 1957th numbers differ - expected: '1', found: '8'
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
Time Limit Exceeded
Test #32:
score: 0
Time Limit Exceeded
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:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%