QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#558110 | #8704. 排队 | byron10000 | 0 | 49ms | 13800kb | C++14 | 2.2kb | 2024-09-11 14:14:46 | 2024-09-11 14:14:47 |
Judging History
answer
#if defined(_USE_PCH_)
#include "pch.hpp"
#else
#include <bits/stdc++.h>
#endif
#define RNG(V_, A_, B_, ...) for(int V_=(A_), V_##_END=(B_) __VA_OPT__(,) __VA_ARGS__; V_<=V_##_END; V_++)
#define IRNG(V_, A_, B_) for(int V_=(A_), V_##_END=(B_); V_>=V_##_END; V_--)
#ifdef _WIN32
#define long __int64
#endif
using namespace std;
const int MAXN=1e6+10,INF=1e9;
int n,qn,ans[MAXN];
struct{ int l,r; } A[MAXN];
struct Qt{ int l,r,id; }; Qt Q[MAXN];
struct SGT{
#define ls (u*2)
#define rs (u*2+1)
#define mid ((l+r)/2)
int mx[MAXN],mn[MAXN],tag[MAXN];
void build(int u,int l,int r){
mx[u]=mn[u]=-INF;
if(l==r) return;
build(ls,l,mid),build(rs,mid+1,r);
}
void pushup(int u){ mx[u]=max(mx[ls],mx[rs]),mn[u]=min(mn[ls],mn[rs]); }
void upd(int u,int x){ mx[u]+=x,mn[u]+=x,tag[u]+=x; }
void pushdown(int u){ upd(ls,tag[u]),upd(rs,tag[u]); tag[u]=0; }
void set(int u,int l,int r,int i,int x){
if(l==r){ mx[u]=mn[u]=x; return; }
pushdown(u);
if(i<=mid) set(ls,l,mid,i,x);
else set(rs,mid+1,r,i,x);
pushup(u);
}
int qry(int u,int l,int r,int i){
if(l==r) return mx[u];
pushdown(u);
if(i<=mid) return qry(ls,l,mid,i);
else return qry(rs,mid+1,r,i);
}
void solve(int u,int l,int r,int vl,int vr){
if(vr<mn[u]||mx[u]<vl) return;
if(vl<=mn[u]&&mx[u]<=vr){ upd(u,1); return; }
pushdown(u);
solve(ls,l,mid,vl,vr),solve(rs,mid+1,r,vl,vr);
pushup(u);
}
#undef ls
#undef rs
#undef mid
} sgt;
int main(){
#if defined(_LOCAL_)
freopen("in","r",stdin);
// freopen("out","w",stdout);
#else
// freopen("c.in","r",stdin);
// freopen("c.out","w",stdout);
#endif
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
cin>>n>>qn;
RNG(i,1,n) cin>>A[i].l>>A[i].r;
RNG(i,1,qn){
int l,r; cin>>l>>r;
Q[i]={l,r,i};
}
sort(Q+1,Q+qn+1,[](auto x,auto y){ return x.r<y.r; });
sgt.build(1,1,n);
RNG(i,1,n,j=0){
sgt.set(1,1,n,i,0);
sgt.solve(1,1,n,A[i].l,A[i].r);
while(j<qn&&Q[j+1].r==i) j++,ans[Q[j].id]=sgt.qry(1,1,n,Q[j].l);
}
RNG(i,1,qn) cout<<ans[i]<<"\n";
}
详细
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
input:
0 8 1 0 1 1 1 2 3 2 2 2 0 3 1 3 2 3 3
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 43ms
memory: 13800kb
input:
1 298913 1 0 3 1 3 1 3 1 3 1 3 1 1 0 1 0 3 3 1 2 1 2 3 5 3 5 1 1 1 3 1 4 3 3 1 3 1 6 3 7 3 2 3 5 3 8 3 2 1 8 3 3 1 4 3 2 3 7 1 3 3 4 1 10 3 14 3 13 1 12 3 4 1 8 1 15 1 16 3 9 3 14 3 10 3 8 3 7 1 16 1 15 3 16 3 13 1 19 3 13 3 1 3 14 1 18 1 22 3 8 1 17 3 18 3 9 1 18 3 9 3 1 1 20 3 11 3 5 3 2 3 22 1 22...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #3:
score: 0
Wrong Answer
Test #20:
score: 0
Wrong Answer
time: 42ms
memory: 11684kb
input:
2 298235 1 0 1 1 3 2 1 0 1 3 3 4 3 3 3 3 3 2 3 4 3 2 3 3 1 2 3 3 1 4 1 2 1 1 3 5 3 8 1 5 1 9 3 10 3 8 3 10 3 5 3 8 3 5 1 2 1 9 3 5 3 7 3 12 3 3 1 6 3 4 3 3 3 11 3 8 3 9 3 7 3 6 3 4 1 12 1 11 3 13 3 13 1 11 3 16 3 6 3 14 3 9 3 5 3 13 1 9 1 17 3 16 3 13 3 5 3 15 3 8 3 4 3 13 1 18 3 15 3 16 3 19 3 4 1 ...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '2', found: '0'
Subtask #4:
score: 0
Wrong Answer
Test #35:
score: 0
Wrong Answer
time: 49ms
memory: 13724kb
input:
3 299743 1 0 1 1 3 1 1 2 3 2 1 0 3 3 3 2 3 1 3 2 2 2 1 3 3 3 3 3 4 3 1 3 2 3 2 2 1 0 3 2 3 1 3 1 1 0 3 2 1 2 1 1 3 2 2 5 2 1 6 1 0 2 5 2 1 7 3 8 3 5 3 5 2 7 5 2 9 4 3 5 3 8 2 6 2 2 3 0 2 2 0 1 1 2 3 1 1 8 2 7 0 3 3 1 12 2 13 9 1 5 2 2 1 2 14 13 1 12 2 1 0 2 12 10 2 15 12 1 0 1 6 3 6 2 3 2 2 17 6 3 4...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '1', found: '0'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%