# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447478 | 2021-07-26T13:32:36 Z | LucaIlie | Trampoline (info1cup20_trampoline) | C++17 | 462 ms | 27944 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1484 KB | 200 token(s): yes count is 21, no count is 179 |
2 | Correct | 5 ms | 1580 KB | 200 token(s): yes count is 70, no count is 130 |
3 | Correct | 4 ms | 1228 KB | 197 token(s): yes count is 25, no count is 172 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 164 ms | 27016 KB | 4000 token(s): yes count is 99, no count is 3901 |
2 | Correct | 163 ms | 27944 KB | 4000 token(s): yes count is 91, no count is 3909 |
3 | Correct | 165 ms | 27588 KB | 4000 token(s): yes count is 4000, no count is 0 |
4 | Correct | 166 ms | 27940 KB | 4000 token(s): yes count is 1991, no count is 2009 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 352 ms | 27724 KB | 200000 token(s): yes count is 110486, no count is 89514 |
2 | Correct | 340 ms | 27796 KB | 200000 token(s): yes count is 114664, no count is 85336 |
3 | Correct | 339 ms | 27740 KB | 200000 token(s): yes count is 86232, no count is 113768 |
4 | Correct | 350 ms | 27796 KB | 200000 token(s): yes count is 94603, no count is 105397 |
5 | Correct | 334 ms | 27728 KB | 200000 token(s): yes count is 94148, no count is 105852 |
6 | Correct | 325 ms | 27780 KB | 200000 token(s): yes count is 97163, no count is 102837 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 1228 KB | 5000 token(s): yes count is 3238, no count is 1762 |
2 | Correct | 7 ms | 1240 KB | 5000 token(s): yes count is 3837, no count is 1163 |
3 | Correct | 6 ms | 1228 KB | 5000 token(s): yes count is 4104, no count is 896 |
4 | Correct | 7 ms | 1236 KB | 5000 token(s): yes count is 3934, no count is 1066 |
5 | Correct | 7 ms | 1228 KB | 5000 token(s): yes count is 3384, no count is 1616 |
6 | Correct | 7 ms | 1228 KB | 5000 token(s): yes count is 3390, no count is 1610 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 415 ms | 27720 KB | 200000 token(s): yes count is 171404, no count is 28596 |
2 | Correct | 406 ms | 27324 KB | 200000 token(s): yes count is 161254, no count is 38746 |
3 | Correct | 368 ms | 27204 KB | 200000 token(s): yes count is 117455, no count is 82545 |
4 | Correct | 462 ms | 27276 KB | 200000 token(s): yes count is 182118, no count is 17882 |
5 | Correct | 373 ms | 27340 KB | 200000 token(s): yes count is 167565, no count is 32435 |
6 | Correct | 369 ms | 27408 KB | 200000 token(s): yes count is 156797, no count is 43203 |
7 | Correct | 365 ms | 27280 KB | 200000 token(s): yes count is 156797, no count is 43203 |
8 | Correct | 362 ms | 27324 KB | 200000 token(s): yes count is 122100, no count is 77900 |
9 | Correct | 430 ms | 27348 KB | 200000 token(s): yes count is 139670, no count is 60330 |
10 | Correct | 417 ms | 27332 KB | 200000 token(s): yes count is 165806, no count is 34194 |
11 | Correct | 459 ms | 27340 KB | 200000 token(s): yes count is 175646, no count is 24354 |
12 | Correct | 342 ms | 27260 KB | 200000 token(s): yes count is 134695, no count is 65305 |
13 | Correct | 353 ms | 27128 KB | 200000 token(s): yes count is 126733, no count is 73267 |
14 | Correct | 374 ms | 27208 KB | 200000 token(s): yes count is 155290, no count is 44710 |
15 | Correct | 344 ms | 27120 KB | 200000 token(s): yes count is 129674, no count is 70326 |