답안 #1027833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1027833 2024-07-19T10:27:24 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
11 / 100
413 ms 21800 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define OYY LLONG_MAX
#define mod 998244353
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define FOR for(int i=1;i<=n;i++)
#define mid (start+end)/2
#define lim 200005
#define fi first
#define se second

int r,c,timer;

vector<int> v[lim];

//int dp[2505][2505];

int xm[lim],ym[lim];

int tut[lim];

map<int,int> mp;

map<pair<int,int>,int> dp;

set<int> st;

inline int f(int x,int y,int tx,int ty){
	if(mp[x]>r || y>c)return 0;
	if(mp[x]==mp[tx] && y<=ty)return 1;
	if(dp.find({x,y})!=dp.end())return dp[{x,y}];
	int cev=0;
	for(auto a:v[x]){
		if(a<y || a>ty)continue;
		cev+=f(x+1,a,tx,ty);
	}
	return dp[{x,y}]=cev;
}

inline void solve(int n){
	FOR{
		cin>>xm[i]>>ym[i];
		st.insert(xm[i]);
	}
	
	for(auto x:st){
		mp[x]=++timer;
		tut[timer]=x;
	}
	
	FOR{
		v[mp[xm[i]]].push_back(ym[i]);
	}
	
	for(int i=1;i<=timer;i++){
		sort(v[i].begin(),v[i].end());
	}
	
	int q;cin>>q;
	while(q--){
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(mp.find(x1)==mp.end()){
			cout<<"No"<<'\n';
			continue;
		}
		int tut=lower_bound(v[mp[x1]].begin(),v[mp[x1]].end(),y1)-v[mp[x1]].begin();
		if(tut>=v[mp[x1]].size()){
			cout<<"No"<<'\n';
			continue;
		}
		if(v[mp[x1]][tut]<=y2){
			cout<<"Yes"<<'\n';
		}
		else cout<<"No"<<'\n';
	}
}

int32_t main(){
	faster
	int n;cin>>r>>c>>n;
	if(n<=5000){
		FOR{
			cin>>xm[i]>>ym[i];
			st.insert(xm[i]);
		}
	
		for(auto x:st){
			mp[x]=++timer;
			tut[timer]=x;
		}
	
		FOR{
			v[mp[xm[i]]].push_back(ym[i]);
		}
	
		int q;cin>>q;
		while(q--){
			int x1,y1,x2,y2;
			cin>>x1>>y1>>x2>>y2;
			dp.clear();
			int tut=f(x1,y1,x2,y2);
			if(tut)cout<<"Yes"<<'\n';
			else cout<<"No"<<'\n';
		}
		return 0;
	}
	solve(n);

	return 0;
}
 

Compilation message

trampoline.cpp: In function 'void solve(long long int)':
trampoline.cpp:72:9: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   if(tut>=v[mp[x1]].size()){
      |      ~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 5208 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 11144 KB expected NO, found YES [1st token]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 10948 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 118 ms 10832 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 147 ms 11092 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 200 ms 11752 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 195 ms 11604 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 373 ms 19944 KB 200000 token(s): yes count is 97163, no count is 102837
# 결과 실행 시간 메모리 Grader output
1 Runtime error 12 ms 10328 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 413 ms 21800 KB expected NO, found YES [23rd token]
2 Halted 0 ms 0 KB -