QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413221#8672. 排队zzafanti#0 357ms31400kbC++232.0kb2024-05-17 09:57:092024-05-17 09:57:10

Judging History

你现在查看的是最新测评结果

  • [2024-05-17 09:57:10]
  • 评测
  • 测评结果:0
  • 用时:357ms
  • 内存:31400kb
  • [2024-05-17 09:57:09]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

struct segment{
  vector<int> minx,maxx,tag;

  segment(int sz){
    minx=maxx=tag=vector<int>(sz*4+10);
  }

  void spread(int u,int val){
    minx[u]+=val;
    maxx[u]+=val;
    tag[u]+=val;
  }

  void dn(int u){
    if(tag[u]){
      spread(u<<1,tag[u]);
      spread(u<<1|1,tag[u]);
      tag[u]=0;
    }
  }

  void add(int u,int l,int r,int L,int R,int val){
    if(maxx[u]<L||minx[u]>R) return ;
    if(minx[u]>=L&&maxx[u]<=R){
      spread(u,val);
      return ;
    }
    if(u>=100) return ;
    dn(u);
    int mid=(l+r)>>1;
    add(u<<1,l,mid,L,R,val);
    add(u<<1|1,mid+1,r,L,R,val);
    minx[u]=min(minx[u<<1],minx[u<<1|1]);
    maxx[u]=max(maxx[u<<1],maxx[u<<1|1]);
  }

  void modify(int u,int l,int r,int pos,int val){
    if(l==r) return minx[u]=maxx[u]=val,void(0);
    dn(u);
    int mid=(l+r)>>1;
    if(pos<=mid) modify(u<<1,l,mid,pos,val);
    else modify(u<<1|1,mid+1,r,pos,val);
    minx[u]=min(minx[u<<1],minx[u<<1|1]);
    maxx[u]=max(maxx[u<<1],maxx[u<<1|1]);
  }

  int query(int u,int l,int r,int pos){
    if(l==r) return minx[u];
    dn(u);
    int mid=(l+r)>>1;
    if(pos<=mid) return query(u<<1,l,mid,pos);
    return query(u<<1|1,mid+1,r,pos);
  }

};

int main(){
  cin.tie(0),cout.tie(0)->sync_with_stdio(false);

  int n,Q;
  cin>>n>>Q;
  vector<int> L(n+1),R(n+1);
  for(int i=1; i<=n; i++){
    cin>>L[i]>>R[i];
  }
  vector<vector<int>> add(n+2),del(n+2);

  for(int i=1; i<=Q; i++){
    int l,r;
    cin>>l>>r;
    add[l].emplace_back(i);
    del[r+1].emplace_back(i);
  }

  vector<int> ans(n+1);
  segment S(Q);
  S.add(1,1,Q,0,0,-1);
  for(int i=1; i<=n+1; i++){
    for(auto p:add[i]){
      S.modify(1,1,Q,p,0);
    }
    //cerr<<i<<endl;
    for(auto p:del[i]){
      ans[p]=S.query(1,1,Q,p);
      S.modify(1,1,Q,p,-1);
    }
    if(i==n+1) break;
    S.add(1,1,Q,L[i],R[i],1);
  }

  for(int i=1; i<=Q; i++){
    cout<<ans[i]<<'\n';
  }

  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 1ms
memory: 3516kb

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: 4ms
memory: 4068kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 numbers differ - expected: '11', found: '0'

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 306ms
memory: 28928kb

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 1564th numbers differ - expected: '11', found: '1'

Subtask #3:

score: 0
Wrong Answer

Test #22:

score: 0
Wrong Answer
time: 357ms
memory: 31400kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 numbers differ - expected: '19141', found: '0'

Subtask #4:

score: 0
Wrong Answer

Test #32:

score: 0
Wrong Answer
time: 286ms
memory: 31332kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
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 numbers differ - expected: '71224', found: '0'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #5:

0%