Submission #992293

# Submission time Handle Problem Language Result Execution time Memory
992293 2024-06-04T08:50:27 Z ramalzaher Trampoline (info1cup20_trampoline) C++14
23 / 100
193 ms 33876 KB
#include <bits/stdc++.h>
#define ll long long  
#define sz size()
#define pb push_back
#define all(x) x.begin() , x.end()
using namespace std;
const int N = 2e3 ; 
bool vis[N][N] ; int r , c , n ; 
map<pair<int,int> , int > mp ;  
void bfs(int xx , int yy , int end ){
	vis[xx][yy] =1 ; 
	queue<pair<int,int> > q ; 
	q.push({xx , yy}) ;
while (q.size())
{
	auto &[x,y]  = q.front() ;
	q.pop() ; 
	if(mp[{x,y}]){
		if(x+1 <= r ){  
		if(!vis[x+1][y]) {
		q.push({x+1 , y}) ; 
		vis[1+x][y] = 1; }}
		if(y+1 <= c ) {
		if(!vis[x][y+1]){
		vis[x][y+1] =1 ; 
		q.push({x , y + 1 });	
			}}
		}
		else {
		if(y+1 <= c ) {
		if(vis[x][y+1])continue ; 
		vis[x][y+1] =1 ; 
		q.push({x , y + 1 });	
			}
		}
	}		
}


int main()
{
	 cin >> r >> c >> n ;
	for (int i = 0; i < n; i++)
	{
		int a, b ; cin >> a >> b; 
		mp[{a,b}]=1;
	}
	int t ; cin >> t; 
	for (int i = 0; i < t; i++)
	{
		int sx , sy  , ex , ey ; cin >> sx >> sy >> ex >> ey; 
		memset(vis ,0 , sizeof vis) ;
		bfs(sx , sy,ex) ;bool ok =0 ;
		for (int j = 0; j < ey+1; j++)
		{
				if(vis[ex][j]==1){ok=1;break;}  }
			if(ok)cout<<"Yes\n" ;	else cout<<"No\n"; 
		
		 
	
	}
	


  return 0;
}
/*
  4 4 3
  1 1 
  2 1 
  3 4 
  1
  1 1 4 3 
 * 
 *  
 * 
 * */

Compilation message

trampoline.cpp: In function 'void bfs(int, int, int)':
trampoline.cpp:16:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   16 |  auto &[x,y]  = q.front() ;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 76 ms 6480 KB 200 token(s): yes count is 21, no count is 179
2 Correct 126 ms 6164 KB 200 token(s): yes count is 70, no count is 130
3 Correct 60 ms 6484 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Runtime error 127 ms 33876 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 173 ms 33616 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 9048 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 193 ms 33832 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -