이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int R, C, N = 0;
bool trampolines[4005][4005];
bool visited[4005][4005];
int xStart = 0;
int yStart = 0;
int xEnd = 0;
int yEnd = 0;
bool dfs(int x, int y){
  if (visited[x][y] == true) return false;
  if (x > R || x < 1 || y > C || y < 1) return false;
  
  visited[x][y] = true;
  if (x == xEnd && y == yEnd){
    return true;
  }
  if (trampolines[x][y] == false){
    dfs(x, y+1);
  }
  else if (trampolines[x][y] == true){
    dfs(x + 1, y);
    dfs(x, y+1);
  }
  return visited[xEnd][yEnd];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  memset(trampolines, false, sizeof(trampolines[0][0])*2500*2500);
  cin >> R >> C >> N;
  for (int i = 0; i < N; i++){
    int temp1 = 0;
    int temp2 = 0;
    cin >> temp1 >> temp2;
    trampolines[temp1][temp2] = true;
  }
  int T = 0;
  cin >> T;
  for (int i = 0; i < T; i++){
    memset(visited, false, sizeof(visited[0][0])*2500*2500);
    cin >> xStart >> yStart >> xEnd >> yEnd;
    bool test = dfs(xStart, yStart);
    if (test){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |