Submission #992307

# Submission time Handle Problem Language Result Execution time Memory
992307 2024-06-04T09:05:15 Z ramalzaher Trampoline (info1cup20_trampoline) C++14
54 / 100
2000 ms 78064 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 = 2505 ; 
int r , c , n ; 
map<pair<int,int> , int > mp ;  
bool check(vector<int> &a){
	for (int i = 0; i < a.size()-1 ; i++)
	{
		if(a[i] > a[i+1] ) return 0  ; 
	}
	
	return 1 ;
	}
bool bfs(int xx , int yy , int endx , int endy  ){
	queue<pair<int,int> > q ; 
	q.push({xx , yy}) ;
while (q.size())
{
	auto &[x,y]  = q.front() ;
	q.pop() ; 
	if(x == endx && y <= endy ) {return 1 ;}
	if(mp[{x,y}]){
		if(x+1 <= r ){  
		q.push({x+1 , y}) ;
		}
		}
		else {
		if(y+1 <= c ) {
		q.push({x , y + 1 });	
			}
		}
	}
	return 0 ; 		
}


int main()
{
	cin >> r >> c >> n ;
	if(r <= 2555 && c <= 2555 ){
	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; 		
		bool ok = bfs(sx , sy , ex, ey) ;
		if(ok)cout<<"Yes\n" ;	else cout<<"No\n";  
	}}else {	map<int,set<int>>mp; 

	for (int i = 0; i < n; i++)
	{
		int a, b ; cin >> a >> b; 
		mp[a].insert(b) ; 
	}
	int t ; cin >> t; 
	for (int i = 0; i < t; i++)
	{
		vector<int> v ; bool ok= 0 ; 
		int sx , sy  , ex , ey ; cin >> sx >> sy >> ex >> ey; 
		v.pb(sy);
		for(int j = sx ; j < ex ; j ++ ){
			auto itt = mp[j].lower_bound(sy) ; 
			if(itt==mp[j].end()) { v.pb(-1);ok=1; break ; }
			v.pb(*itt) ; 
			sy = *itt ; 
			//cout<<sy<<" " ; 
			}
			v.pb(ey);
			//for(auto it : v)cout<<it<<" ";//cout<<endl; 
			if(check(v)&&ok==0)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 'bool check(std::vector<int>&)':
trampoline.cpp:11:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for (int i = 0; i < a.size()-1 ; i++)
      |                  ~~^~~~~~~~~~~~
trampoline.cpp: In function 'bool bfs(int, int, int, int)':
trampoline.cpp:23:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |  auto &[x,y]  = q.front() ;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1116 KB 200 token(s): yes count is 21, no count is 179
2 Correct 8 ms 1116 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 1116 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 953 ms 78064 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 978 ms 77544 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 511 ms 13204 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 1437 ms 69716 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Correct 710 ms 18004 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 692 ms 22132 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 682 ms 21944 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 698 ms 22356 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 765 ms 22268 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 799 ms 28156 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 600 KB expected NO, found YES [17th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2072 ms 18152 KB Time limit exceeded
2 Halted 0 ms 0 KB -