답안 #525317

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
525317 2022-02-11T09:59:41 Z ksu2009en Trampoline (info1cup20_trampoline) C++14
23 / 100
2000 ms 84100 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, m, k, t;

ll d[5007][5007];
char a[5007][5007];

void clear_me(){
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= m;j ++)
            d[i][j] = 0;
}

int main(){
    cin >> n >> m >> k;

    for(int i = 0; i <= min((ll)(5000), n); i++)
        for(int j = 0; j <= min((ll)(5000), m); j++)
            a[i][j] = 'B';

    set<pair<ll, ll>> st;

    for(int i = 0; i < k; i++){
        ll aa, bb;
        cin >> aa >> bb;
        st.insert({aa, bb});
        if(aa > 5000 || bb > 5000){

            continue;
        }

        a[aa][bb] = 'G';
    }

    cin >> t;

    while(t--){

        ll x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if(m > 5000 || n > 5000){
            pair<ll, ll> p = {x1, y1};
            auto u = lower_bound(st.begin(), st.end(), p);
            auto u2 = *u;

            //cout << u2.first << ' ' << u2.second << endl;

            if(u == st.end() || u2.first > x1 || u2.second > y2){
                cout << "No" << endl;
                continue;
            }


            cout << "Yes" << endl;
            continue;
        }
        clear_me();
        d[x1][y1] = 1;

        for(int i = min(x1, x2); i <= max(x1, x2); i++){
            for(int j = min(y1, y2); j <= max(y1, y2); j++){
                if(d[i][j - 1] == 1 || (a[i - 1][j] == 'G' && d[i - 1][j] == 1))
                    d[i][j] = 1;
            }
        }

        if(d[x2][y2] == 1)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }


    return 0;
}

/*

5 8 3
2 3
3 7
5 2
1
3 2 4 8

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2764 KB 200 token(s): yes count is 21, no count is 179
2 Correct 10 ms 2328 KB 200 token(s): yes count is 70, no count is 130
3 Correct 10 ms 2636 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 84100 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2091 ms 37196 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 638 ms 25112 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2075 ms 37240 KB Time limit exceeded
2 Halted 0 ms 0 KB -