답안 #784310

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
784310 2023-07-16T02:05:53 Z Trunkty Trampoline (info1cup20_trampoline) C++14
100 / 100
1078 ms 98684 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll

int r,c,n,t;
map<int,set<int>> mp;
map<pair<int,int>,int> pos;
map<int,pair<int,int>> rev;
int nextpos=1;
int jump[200005][21];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> r >> c >> n;
    for(int i=1;i<=n;i++){
        int a,b;
        cin >> a >> b;
        mp[a].insert(b);
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        int x = it->first;
        set<int> s = it->second;
        for(int y:s){
            pos[{x,y}] = nextpos;
            rev[nextpos] = {x,y};
            nextpos++;
        }
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        int x = it->first;
        set<int> s = it->second;
        for(int y:s){
            auto it = mp[x+1].lower_bound(y);
            if(it!=mp[x+1].end()){
                jump[pos[{x,y}]][0] = pos[{x+1,(*it)}];
            }
        }
    }
    for(int j=1;j<=20;j++){
        for(int i=1;i<=n;i++){
            jump[i][j] = jump[jump[i][j-1]][j-1];
        }
    }
    cin >> t;
    for(int i=1;i<=t;i++){
        int x1,y1,x2,y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if(x1>x2){
            cout << "No" << "\n";
        }
        else if(x1==x2){
            if(y1<=y2){
                cout << "Yes" << "\n";
            }
            else{
                cout << "No" << "\n";
            }
        }
        else{
            auto it = mp[x1].lower_bound(y1);
            if(it==mp[x1].end()){
                cout << "No" << "\n";
                continue;
            }
            int p = pos[{x1,(*it)}];
            for(int j=20;j>=0;j--){
                if(x1+(1<<j)<=x2-1){
                    x1 += (1<<j);
                    p = jump[p][j];
                }
            }
            if(p==0 or rev[p].second>y2){
                cout << "No" << "\n";
            }
            else{
                cout << "Yes" << "\n";
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 3284 KB 200 token(s): yes count is 21, no count is 179
2 Correct 9 ms 3756 KB 200 token(s): yes count is 70, no count is 130
3 Correct 7 ms 2772 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Correct 300 ms 69712 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 284 ms 69736 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 284 ms 69244 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 291 ms 69708 KB 4000 token(s): yes count is 1991, no count is 2009
# 결과 실행 시간 메모리 Grader output
1 Correct 684 ms 85252 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 701 ms 83308 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 600 ms 80516 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 627 ms 80296 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 672 ms 80168 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 744 ms 86184 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 2260 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 10 ms 2260 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 9 ms 3260 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 8 ms 2396 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 9 ms 2388 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 8 ms 2388 KB 5000 token(s): yes count is 3390, no count is 1610
# 결과 실행 시간 메모리 Grader output
1 Correct 986 ms 87556 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 792 ms 81868 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 709 ms 80452 KB 200000 token(s): yes count is 117455, no count is 82545
4 Correct 1078 ms 98684 KB 200000 token(s): yes count is 182118, no count is 17882
5 Correct 802 ms 91412 KB 200000 token(s): yes count is 167565, no count is 32435
6 Correct 676 ms 83348 KB 200000 token(s): yes count is 156797, no count is 43203
7 Correct 713 ms 83296 KB 200000 token(s): yes count is 156797, no count is 43203
8 Correct 677 ms 81304 KB 200000 token(s): yes count is 122100, no count is 77900
9 Correct 985 ms 86128 KB 200000 token(s): yes count is 139670, no count is 60330
10 Correct 1056 ms 86244 KB 200000 token(s): yes count is 165806, no count is 34194
11 Correct 1062 ms 92600 KB 200000 token(s): yes count is 175646, no count is 24354
12 Correct 735 ms 85904 KB 200000 token(s): yes count is 134695, no count is 65305
13 Correct 713 ms 85644 KB 200000 token(s): yes count is 126733, no count is 73267
14 Correct 739 ms 80260 KB 200000 token(s): yes count is 155290, no count is 44710
15 Correct 686 ms 83356 KB 200000 token(s): yes count is 129674, no count is 70326