Submission #332229

# Submission time Handle Problem Language Result Execution time Memory
332229 2020-12-01T18:03:22 Z evpipis Trampoline (info1cup20_trampoline) C++11
100 / 100
469 ms 37996 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef pair<int, int> ii;

const int len = 2e5+5, lg = 30, inf = 1e9+5;
ii point[len];
int k, dp[len][lg];

int fir(int x, int y){
    int l = 1, r = k, ans = k+1;
    while (l <= r){
        int mid = (l+r)/2;
        if (point[mid] >= mp(x, y))
            ans = mid, r = mid-1;
        else
            l = mid+1;
    }

    if (ans == k+1 || point[ans].fi > x)
        return 0;
    return ans;
}

int main(){
    int n, m, q;
    scanf("%d %d %d", &n, &m, &k);

    for (int i = 1; i <= k; i++)
        scanf("%d %d", &point[i].fi, &point[i].se);
    point[0] = mp(inf, inf);

    sort(point+1, point+1+k);

    for (int i = 1; i <= k; i++)
        dp[i][0] = fir(point[i].fi+1, point[i].se);
    for (int j = 1; j < lg; j++)
        for (int i = 1; i <= k; i++)
            dp[i][j] = dp[dp[i][j-1]][j-1];

    scanf("%d", &q);
    while (q--){
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

        if (x1 > x2 || y1 > y2)
            printf("No\n");
        else if (x1 == x2)
            printf("Yes\n");
        else{
            int i = fir(x1, y1), dif = x2-x1-1;
            for (int j = 0; j < lg; j++)
                if (dif&(1<<j))
                    i = dp[i][j];

            if (point[i].se <= y2)
                printf("Yes\n");
            else
                printf("No\n");
        }
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |     scanf("%d %d %d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   34 |         scanf("%d %d", &point[i].fi, &point[i].se);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
trampoline.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1388 KB 200 token(s): yes count is 21, no count is 179
2 Correct 5 ms 1644 KB 200 token(s): yes count is 70, no count is 130
3 Correct 5 ms 1260 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 163 ms 25324 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 163 ms 25452 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 160 ms 25580 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 189 ms 25324 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 290 ms 26092 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 304 ms 37868 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 302 ms 37868 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 329 ms 37912 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 329 ms 37868 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 319 ms 37740 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1004 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 6 ms 1260 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 6 ms 1260 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 6 ms 1260 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 7 ms 1260 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 6 ms 1260 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 462 ms 26220 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 432 ms 26220 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 326 ms 26244 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 469 ms 37740 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 372 ms 37896 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 349 ms 37996 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 343 ms 37868 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 323 ms 37868 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 439 ms 37740 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 462 ms 37868 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 468 ms 37740 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 299 ms 37868 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 295 ms 37868 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 416 ms 37868 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 309 ms 37800 KB 200000 token(s): yes count is 129674, no count is 70326