# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
721603 | Erkinoff_Mohammed | Event Hopping (BOI22_events) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "art.h"
using namespace std;
#define INF 2000000000
#define INFLL 3000000000000000000LL
#define ll long long
int main() {
cin.tie(0)->sync_with_stdio(0);
int n,q;
cin>>n>>q;
pair<pair<int,int>,int>arr[n];
for(int i=0;i<n;i++){
int l,r;
cin>>l>>r;
arr[i]={{l,r},i+1};
}
sort(arr,arr+n);
map<int,int>mp;
for(int i=0;i<n;i++){
mp[arr[i].second]=i;
}
cout<<"\n";
while(q--){
int a,b;
cin>>a>>b;
int out=mp[b]-mp[a];
if(out<0)cout<<"impossible\n";
else cout<<out<<"\n";
}
}