답안 #426932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426932 2021-06-14T10:57:28 Z lyc Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 12648 KB
#include <bits/stdc++.h>
using namespace std;

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef pair<int,int> ii;

const int mxN = 2e5+5;
const int lgN = 18;

int R, C, N, T, A[mxN], B[mxN];
map<int,vector<ii>> rows;
int pa[mxN][lgN];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    cin >> R >> C >> N;
    FOR(i,1,N){
        int a, b; cin >> a >> b; 
        A[i] = a, B[i] = b;
        rows[a].push_back(ii(b,i));
    }

    FOR(i,1,N) {
        int bst = 0;
        FOR(j,1,N) if (i != j) {
            if (A[j] == A[i]-1 && B[j] <= B[i]) {
                if (bst == 0 || B[j] > B[bst]) bst = j;
            }
        }
        pa[i][0] = bst;
    }

    FOR(k,1,lgN-1) FOR(i,1,N) pa[i][k] = pa[pa[i-1][k-1]][k-1];

    cin >> T;
    FOR(i,1,T){
        int a, b, c, d; cin >> a >> b >> c >> d;

        bool ok = 1;
        if (a > c || b > d) ok = 0;
        else if (a < c) {
            ok = 0;
            for (auto& [x,i] : rows[c-1]) if (x <= d) {
                int u = i;
                RFOR(k,lgN-1,0){
                    if (pa[u][k] && A[pa[u][k]] >= a) u = pa[u][k];
                }
                ok |= A[u] == a && B[u] >= b;
            }
        }

        cout << (ok ? "Yes" : "No") << '\n';
    }
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:49:24: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   49 |             for (auto& [x,i] : rows[c-1]) if (x <= d) {
      |                        ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 113 ms 1188 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2080 ms 5912 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2066 ms 4452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 1056 KB expected YES, found NO [5th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2075 ms 12648 KB Time limit exceeded
2 Halted 0 ms 0 KB -