# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
721603 | 2023-04-11T05:28:45 Z | Erkinoff_Mohammed | Event Hopping (BOI22_events) | C++14 | 0 ms | 0 KB |
#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"; } }