#include <bits/stdc++.h>
#define all(v) ((v).begin(),(v).end())
#define ll long long
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll mxN = 1e5 + 2;
using namespace std;
pair<int,int>a[mxN];
pair<int,int>og[mxN];
signed main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0 );
int n,q;
cin >>n>>q;
for(int i = 0;i < n;i++){
cin >>a[i].F>>a[i].S;
og[i] = a[i];
}
sort(a,a + n);
while(q--){
int s,e;
cin >>s>>e;
auto x = og[s - 1],y = og[e - 1];
int ans = 0;
int i = lower_bound(a,a + n,x) - a;
int j = lower_bound(a,a + n,y) - a;
if(i > j) ans = -1;
while(i < j){
int nxt = -1;
int lt = -1;
i++;
while(i < n){
if(a[i].F <= x.S && a[i].S >= x.S && a[i].S <= y.S){
if(nxt == -1 || a[i].S >= a[nxt].S){
nxt = i;
}
lt = i;
}
if(a[i] == y) break;
i++;
}
if(nxt == -1){
ans = -1;
break;
}
x = a[nxt];
i = lt;
ans++;
}
if(ans != -1) cout<<ans<<'\n';
else cout<<"impossible\n";
}
}
Compilation message
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | if(v.size() != N) {
| ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(v.size() != N) {
| ~~~~~~~~~^~~~
/usr/bin/ld: /tmp/cc0vqJ7y.o: in function `main':
interface.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cclGeI6A.o:art.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc0vqJ7y.o: in function `main':
interface.cpp:(.text.startup+0x16): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status