Submission #1027761

# Submission time Handle Problem Language Result Execution time Memory
1027761 2024-07-19T09:45:16 Z DangerNoodle7591 Trampoline (info1cup20_trampoline) C++17
0 / 100
122 ms 18812 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
//#define int long long int
#define endl '\n'
#define N 800
#define M 800
#define big 2147483647 
#define bigg 9223372036854775807 
#define pb push_back
#define p push
#define ins insert
#define f first
#define s second

tuple<int,int,int> bfs[M];

vector<int> adj[N], comprez;
vector<pair<int,int>> ikinci;
int gittik[M];
inline void dfs(int x,int a,int b){
	if(x==-1)return;
	if(gittik[x])return ;
	gittik[x]=1;
	pair<int,int> pa={a+1,b};

	int yeni=(upper_bound(ikinci.begin(),ikinci.end(),pa)-ikinci.begin())-1;
	if(ikinci[yeni].f==a+1&&ikinci[yeni].s==b&&gittik[yeni]==0){
		bfs[x]={yeni,a+1,b};
		dfs(yeni,a+1,b);
		return;
	}

	int kim=(lower_bound(comprez.begin(),comprez.end(),a)-comprez.begin());
	int yer=(lower_bound(adj[kim].begin(),adj[kim].end(),b)-adj[kim].begin());

	if(yer!=adj[kim].size()){
		pa={a,adj[kim][yer]};
		yeni=(upper_bound(ikinci.begin(),ikinci.end(),pa)-ikinci.begin())-1;
		bfs[x]={yeni,a,adj[kim][yer]};
		dfs(yeni,a,adj[kim][yer]);
		return;
	}
	bfs[x]={-1,-1,-1};
}

inline bool defese(int x,int a,int b,int s,int e){
	if(a>s||b>e)return 0;
	if(a==s){
		return 1;
	}

	int aa,bb,cc;tie(aa,bb,cc)=bfs[x];
	if(a==-1)return 0;
	return defese(aa,bb,cc,s,e);
}
inline void qua(){
	int x,y,a,b;cin>>x>>y>>a>>b;
	if(x==a){
		if(y<=b)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		return;
	}
	if(x>a||y>b){
		cout<<"No"<<endl;
		return;
	}

	int kim=(lower_bound(comprez.begin(),comprez.end(),x)-comprez.begin());
	if(kim==comprez.size()||comprez[kim]!=x){
		cout<<"No"<<endl;
		return;
	}
	int yer=(lower_bound(adj[kim].begin(),adj[kim].end(),y)-adj[kim].begin());
	if(yer==adj[kim].size()){
		cout<<"No"<<endl;
		return;
	}

	pair<int,int> pa={x,adj[kim][yer]};
	int yeni=(upper_bound(ikinci.begin(),ikinci.end(),pa)-ikinci.begin())-1;
	int ok=defese(yeni,x,adj[kim][yer],a,b);
	if(ok)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
inline void solve(){
	int r,c,n;cin>>r>>c>>n;
	vector<pair<int,int>> v;
	ikinci.clear();
	comprez.clear();
	vector<int> yedek;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		v.pb({b,a});
		yedek.pb(a);yedek.pb(b);
		yedek.pb(a+1);
		ikinci.pb({a,b});
		ikinci.pb({a+1,b});
	}
	sort(v.begin(),v.end());
	sort(yedek.begin(),yedek.end());
	sort(ikinci.begin(),ikinci.end());
	comprez.pb(yedek[0]);
	for(int i=1;i<n*3;i++){
		if(yedek[i]!=yedek[i-1])comprez.pb(yedek[i]);
		if(i<=n*2+5){
			gittik[i]=0;
		}
		adj[i].clear();
	}
	adj[0].clear();
	gittik[0]=0;
	for(auto u:v){
		int yer=u.s;
		int kim=lower_bound(comprez.begin(),comprez.end(),yer)-comprez.begin();
		adj[kim].pb(u.f);
	}
	for(int i=0;i<(int)ikinci.size();i++){
		if(gittik[i])continue;
		dfs(i,ikinci[i].f,ikinci[i].s);
	}
	/*for(int i=0;i<(int)ikinci.size();i++){
		int a,b,c;tie(a,b,c)=bfs[i];
		cout<<a<<" "<<b<<" "<<c<<endl;
	}*/
	int q;cin>>q;
	while(q--){
		qua();
	}


}


signed main(){
	lalala;
	solve();
	
}

Compilation message

trampoline.cpp: In function 'void dfs(int, int, int)':
trampoline.cpp:38:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  if(yer!=adj[kim].size()){
      |     ~~~^~~~~~~~~~~~~~~~~
trampoline.cpp: In function 'void qua()':
trampoline.cpp:71:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |  if(kim==comprez.size()||comprez[kim]!=x){
      |     ~~~^~~~~~~~~~~~~~~~
trampoline.cpp:76:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |  if(yer==adj[kim].size()){
      |     ~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 122 ms 16092 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 118 ms 17632 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 1112 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 120 ms 18812 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -