답안 #426850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426850 2021-06-14T10:27:47 Z lyc Trampoline (info1cup20_trampoline) C++14
11 / 100
749 ms 26592 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 (auto& [a, v] : rows) {
        sort(ALL(v));
        auto& p = rows[a-1];
        auto it = p.begin();
        for (auto& [b, i] : v) {
            while (it != p.end() && next(it) != p.end() && next(it)->first <= b) ++it;
            pa[i][0] = (it == p.end() ? 0 : it->second);
            FOR(k,1,lgN-1) pa[i][k] = pa[pa[i][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) ok = 0;
        else if (a == c) ok = (b <= d);
        else if (b > d) ok = 0;
        else {
            auto it = lower_bound(ALL(rows[c-1]), ii(d+1,0));
            if (it == rows[c].begin()) ok = 0;
            else {
                auto u = (--it)->second;
                RFOR(k,lgN-1,0) if (pa[u][k] && A[pa[u][k]] >= a) {
                    u = pa[u][k];
                }
                if (B[u] < b) ok = 0;
            }
        }

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

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:29:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |     for (auto& [a, v] : rows) {
      |                ^
trampoline.cpp:33:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   33 |         for (auto& [b, i] : v) {
      |                    ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 1100 KB expected NO, found YES [18th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 138 ms 19072 KB expected NO, found YES [6th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 317 ms 18804 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 333 ms 18684 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 322 ms 18884 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 446 ms 19336 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 382 ms 19396 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 625 ms 25200 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 716 KB expected NO, found YES [104th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 749 ms 26592 KB expected NO, found YES [23rd token]
2 Halted 0 ms 0 KB -