# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
447388 | 2021-07-26T08:30:54 Z | LucaIlie | Trampoline (info1cup20_trampoline) | C++17 | 316 ms | 28324 KB |
#include <stdio.h> #include <algorithm> #define MAX_K 200000 #define MAX_LOG_LIN 17 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 ( i = 0; i < k; i++ ) { for ( j = 1; j <= MAX_LOG_LIN; j++ ) { 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 ) 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 ( v[p].l + 1 == f.l && v[p].c <= f.c ) printf( "YES\n" ); else printf( "NO\n" ); } } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 972 KB | expected YES, found NO [1st token] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 98 ms | 15860 KB | expected YES, found NO [3rd token] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 269 ms | 16572 KB | 200000 token(s): yes count is 110486, no count is 89514 |
2 | Correct | 264 ms | 28268 KB | 200000 token(s): yes count is 114664, no count is 85336 |
3 | Correct | 262 ms | 28152 KB | 200000 token(s): yes count is 86232, no count is 113768 |
4 | Correct | 316 ms | 28324 KB | 200000 token(s): yes count is 94603, no count is 105397 |
5 | Correct | 274 ms | 28316 KB | 200000 token(s): yes count is 94148, no count is 105852 |
6 | Correct | 303 ms | 28220 KB | 200000 token(s): yes count is 97163, no count is 102837 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 588 KB | expected YES, found NO [1st token] |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 279 ms | 16464 KB | expected YES, found NO [1st token] |
2 | Halted | 0 ms | 0 KB | - |