Submission #519988

# Submission time Handle Problem Language Result Execution time Memory
519988 2022-01-28T02:54:42 Z QuantumK9 Trampoline (info1cup20_trampoline) C++17
0 / 100
2000 ms 9448 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple 

using namespace std;

ll r,c,n,t;
vector<vector<char> > grid;
vector<vector<bool> > explored;

bool explore( ll x1, ll y1, ll x2, ll y2 ){

    if( x1 == x2 && y1 == y2 ){ return true; }
    else if ( x1 == r-1 && y1 == c-1 ){ return false; }
    else{
        bool kaya = false;
        if ( y1 != c-1 ){ kaya = kaya || explore( x1, y1+1, x2, y2 ); }
        if ( x1 != r-1 && grid[x1][y1] == 'G' ){ kaya = kaya || explore(x1+1,y1,x2,y2); }
        return kaya;
    }
}

void solve(){

    // start with ST1

    cin >> r >> c >> n;

    grid.resize(r);
    explored.resize(r);

    for( int i = 0; i < r; i++ ){ explored[i].resize(c,false); grid[i].resize(c,'B'); }

    while(n--){
        ll x,y; cin >> x >> y; x--; y--;
        grid[x][y] = 'G';
    }

    cin >> t;

    while(t--){
        for( int i = 0; i < r; i++ ){ for( int j = 0; j < c; j++ ){ explored[i][j] = false; } } 
        ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; x1--; y1--; x2--; y2--;
        cout << ( explore(x1,y1,x2,y2) ? "Yes" : "No" ) << endl;
    }

    return;

}

int main(){

    //freopen( "input.txt", "r", stdin );

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; //cin>>t;
    while(t--){ solve(); }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2101 ms 432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 9448 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 588 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -