#include <stdio.h>
#include <algorithm>
#define MAX_K 200000
#define MAX_LOG_LIN 30
using namespace std;
struct punct {
int l, c;
};
int nxt[MAX_K][MAX_LOG_LIN + 1];
struct punct v[MAX_K];
bool cmp ( struct punct a, struct punct b ) {
if ( a.l == b.l )
return a.c < b.c;
return a.l < b.l;
}
int main() {
int n, m, k, t, lin, st, dr, mij, p, i, j;
struct punct s, f;
scanf( "%d%d%d", &n, &m, &k );
for ( i = 0; i < k; i++ )
scanf( "%d%d", &v[i].l, &v[i].c );
sort( v, v + k, cmp );
j = 0;
for ( i = 0; i < k; i++ ) {
while ( j < k && (v[j].l < v[i].l + 1 || (v[j].l == v[i].l + 1 && v[j].c < v[i].c)) )
j++;
if ( j < k && v[j].l == v[i].l + 1 )
nxt[i][0] = j;
else
nxt[i][0] = -1;
}
for ( j = 1; j <= MAX_LOG_LIN; j++ ) {
for ( i = 0; i < k; i++ ) {
if ( nxt[i][j - 1] != -1 )
nxt[i][j] = nxt[nxt[i][j - 1]][j - 1];
else
nxt[i][j] = -1;
}
}
scanf( "%d", &t );
for ( i = 0; i < t; i++ ) {
scanf( "%d%d%d%d", &s.l, &s.c, &f.l, &f.c );
if ( s.l == f.l ) {
if ( s.c <= f.c )
printf( "Yes\n" );
else
printf( "No\n" );
} else if ( f.l - s.l > k || f.l - s.l < 0 )
printf( "No\n" );
else {
st = -1;
dr = k - 1;
while ( dr - st > 1 ) {
mij = (st + dr) / 2;
if ( v[mij].l < s.l || (v[mij].l == s.l && v[mij].c < s.c) )
st = mij;
else
dr = mij;
}
if ( v[dr].l != s.l )
printf( "No\n" );
else {
lin = f.l - s.l - 1;
p = dr;
for ( j = MAX_LOG_LIN; j >= 0; j-- ) {
if ( (lin & (1 << j)) > 0 ) {
if ( p != -1 )
p = nxt[p][j];
}
}
if ( p != -1 && v[p].l + 1 == f.l && v[p].c <= f.c )
printf( "Yes\n" );
else
printf( "No\n" );
}
}
}
return 0;
}
Compilation message
trampoline.c:2:10: fatal error: algorithm: No such file or directory
2 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.