답안 #892897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892897 2023-12-26T06:42:31 Z yuhong Trampoline (info1cup20_trampoline) C++17
23 / 100
2000 ms 111444 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#define endl '\n'
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define sz(x) (int)x.size()
#define int long long
#define float double
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rep(i,a,b) for (ll i = a; i<b; i++)
#define repo(i,a,b) for (int i = a; i>=b; i--)
#define fi first
#define se second
//int decrow[4] = {-1,0,1,0};
//int deccol[4] = {0,1,0,-1};
//int dp[100001][100001];
//int arr[100001];
int dy[8] = {0,  0, 1, -1, 1, -1 , 1, -1};
int dx[8] = {1, -1, 0,  0, 1, -1, -1,  1};
const int MAXN = 1e6;
const int MOD = 1e9+7;
const int INF = 1e18;
int n,c,r;
int total = 0;
int ans = 0;
vi v;
set<pii> st;
int visited[5001][5001];
void traverse(int i,int j){
	if(visited[i][j]==1){
		return;
	}
	visited[i][j] = 1;
	if(st.find({i,j}) != st.end()){
		if(i+1>=r && j+1>=c){
			return;
		}
		if(i+1<r){
			traverse(i+1,j);
		}
		if(j+1<c){
			traverse(i,j+1);
		}
		
	}else{
		if(j+1<c){
			traverse(i,j+1);
		}else{
			return;
		}
	}
}
void solve(){
  int t;
  cin>>r>>c>>n;
  for(int i = 0;i<n;i++){
	  int a,b;
	  cin>>a>>b;
	  st.insert({a-1,b-1});
  }
  cin>>t;
  while(t--){
	  int a,b,aa,bb;
	  cin>>a>>b>>aa>>bb;
	  a--,b--,aa--,bb--;
	  for(int i=0;i<r;i++){
		  for(int j= 0;j<c;j++){
			  visited[i][j] = 0;
		  }
	  }
	  traverse(a,b);
	  if(visited[aa][bb]==1){
		  cout<<"Yes"<<endl;
	  }else{
		  cout<<"No"<<endl;
	  }
  }
}	



int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
  int q;
  q =1;
  while(q--){
    solve();
  }
  return 0;
}





# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 9052 KB 200 token(s): yes count is 21, no count is 179
2 Correct 50 ms 7512 KB 200 token(s): yes count is 70, no count is 130
3 Correct 20 ms 9048 KB 197 token(s): yes count is 25, no count is 172
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2047 ms 111444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 96 ms 25944 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1112 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 110 ms 25852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -