답안 #523640

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523640 2022-02-08T02:41:30 Z iskhakkutbilim Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 1048580 KB
// Author: Tazhibaev Iskhak
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<int, int> ,null_type,less< pair<int, int> >,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;
const long double pi = acos((long double) - 1.0);
const double eps = (double)1e-9;
const int INF = 1e9 + 7;
    #define ff         first
    #define ss         second
    #define ll         long long
    #define ld		   long double
    #define pb         push_back
void usaco( string filename){
  freopen((filename+".in").c_str(), "r", stdin);
  freopen((filename+".out").c_str(), "w", stdout);
}
int r, c, n;

bool in(int i, int j){
	if(i >= 1 and i <= r and j >= 1 and j <= c) return true;
			return false;
}


main(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(nullptr); cout.tie(nullptr);
	 cin >> r >> c >> n;
	 map<pair<int, int> , int> mp;
	 for(int i = 0;i < n; i++){
	 	int x, y; 
	 	cin >> x >> y;
	 	mp[{x, y}] = 1;
	 }		 
     int T;
     cin >> T;
     while(T--){
     	pair<int, int> start;
     	cin >> start.ff >> start.ss;
     	pair<int, int> end;
     	cin >> end.ff >> end.ss;
     	
     	if(end.ff - start.ff == 1 and end.ss >= end.ff){
     		if(mp[start] == 1) cout << "Yes";
     		else cout << "No";
     		continue;
     	}else if(end.ff < start.ff ){
     		cout << "No" << "\n";
     		continue;
     	}else if(end.ss < start.ss){
     		cout << "No" << "\n";
     		continue;
     	}
     	
     	queue< pair<int, int> > q;
     	int dis[r + 1][c + 1];
     	memset(dis, -1, sizeof(dis));
     	dis[start.ff][start.ss] = 0;
     	q.push(start);
     	while(!q.empty()){
     		if(dis[end.ff][end.ss] != -1){
     			break;	
     		}
     		pair<int, int> v = q.front();
     		q.pop();
     		if(mp[{v.ff, v.ss}] == 1 and in(v.ff +1, v.ss) and dis[v.ff + 1][v.ss] == -1){
     			dis[v.ff + 1][v.ss] = dis[v.ff][v.ss] + 1;
     			q.push({v.ff + 1, v.ss});
     		}
     		if(in(v.ff, v.ss+1) and dis[v.ff][v.ss + 1] == -1){
     			dis[v.ff][v.ss + 1] = dis[v.ff][v.ss] + 1;
     			q.push({v.ff, v.ss+1});
     		}
     	}
     	if(dis[end.ff][end.ss] == -1) cout << "No";
     	else cout << "Yes";
     	cout << "\n";
     }
    return 0;
}

Compilation message

trampoline.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main(){
      | ^~~~
trampoline.cpp: In function 'void usaco(std::string)':
trampoline.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen((filename+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   freopen((filename+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 2636 KB YES or NO expected, but YESNO found [59th token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2091 ms 230948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 481 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 384 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 479 ms 1048580 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -