답안 #369195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
369195 2021-02-20T21:03:29 Z doowey Trampoline (info1cup20_trampoline) C++14
11 / 100
610 ms 56920 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)4e5 + 10;
const int LOG = 19;
int ii[N], jj[N];
int nx[LOG][N];

vector<pii> imp;

int fin(pii xx){
    return lower_bound(imp.begin(), imp.end(), xx) - imp.begin();
}

int main(){
    fastIO;
    int r,c,t;
    cin >> r >> c >> t;
    set<pii> aq;

    for(int id = 0; id < t; id ++ ){
        cin >> ii[id] >> jj[id];
        aq.insert(mp(ii[id], jj[id]));
        imp.push_back(mp(ii[id], jj[id]));
        imp.push_back(mp(ii[id] + 1, jj[id]));
    }
    sort(imp.begin(), imp.end());
    imp.resize(unique(imp.begin(), imp.end()) - imp.begin());
    int m = imp.size();
    int ni = -1;
    for(int i = m - 1; i >= 0; i -- ){
        if(i == m - 1 || imp[i].fi != imp[i + 1].fi)
            ni = -1;
        if(aq.count(imp[i])){
            ni = fin(mp(imp[i].fi + 1, imp[i].se));
        }
        nx[0][i] = ni;
    }
    for(int i = 1; i < LOG; i++ ){
        for(int j = 0 ;j < m ; j ++ ){
            if(nx[i-1][j] != -1){
                nx[i][j]=nx[i-1][nx[i-1][j]];
            }
        }
    }
    int q;
    cin >> q;
    int i1, j1, i2, j2;
    int st;
    for(int id = 0; id < q; id ++ ){
        cin >> i1 >> j1 >> i2 >> j2;
        if(i1 > i2 || j1 > j2){
            cout << "No\n";
        }
        else{
            if(i1 == i2){
                cout << "Yes\n";
            }
            else{
                st = lower_bound(imp.begin(), imp.end(), mp(i1, j1)) - imp.begin();
                if(st == imp.size() || imp[st].fi != i1){
                    cout << "No\n";
                }
                else{
                    for(int q = 0; q < LOG; q ++ ){
                        if(((i2-i1)&(1<<q))){
                            if(st != -1) st = nx[q][st];
                        }
                    }
                    if(st != -1 && imp[st].se <= j2){
                        cout << "Yes\n";
                    }
                    else{
                        cout << "No\n";
                    }
                }
            }
        }
    }
    return 0;
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:70:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                 if(st == imp.size() || imp[st].fi != i1){
      |                    ~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 2536 KB expected NO, found YES [9th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 291 ms 45652 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 451 ms 55636 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 461 ms 56532 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 479 ms 56544 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 468 ms 56920 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 454 ms 56660 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 469 ms 56788 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1900 KB expected NO, found YES [104th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 609 ms 56736 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 610 ms 56616 KB 200000 token(s): yes count is 161254, no count is 38746
3 Incorrect 460 ms 56800 KB expected NO, found YES [1300th token]
4 Halted 0 ms 0 KB -