QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#344205#4894. 学姐买瓜ANIG0 0ms0kbC++14947b2024-03-03 18:33:162024-03-03 18:33:17

Judging History

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

  • [2024-03-03 18:33:17]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-03-03 18:33:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=3e5+5;
int n,m,val[N],fa[N];
map<int,int>q;
void add(int l,int r){
    auto w=q.lower_bound(l);
    if(w!=q.end()&&(*w).second<=r)return;
    while(q.size()){
        w=q.upper_bound(l);
        if(w!=q.begin()){
            w--;
            if((*w).second>=r){
                fa[(*w).first]=(*w).first+1;
                val[(*w).first]=0;
                q.erase(w);
            }else break;
        }else break;
    }
    q[l]=r;
    fa[l]=r;
    val[l]=1;
}
int solve(int l,int r){
    int res=0,i;
    for(i=l;i<r;i=fa[i])res+=val[i];
    res-=i>r;
    return res;
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>m>>n;
    for(int i=1;i<=n;i++)fa[i]=i+1;
    while(m--){
        int op,l,r;
        cin>>op>>l>>r;
        if(op==1)add(l,r);
        else cout<<solve(l,r)<<'\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

11 13
2 4 4
1 11 12
1 1 5
1 2 3
1 2 10
2 2 8
1 6 6
2 2 10
1 6 11
2 2 3
2 2 13

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%