Submission #1027585

# Submission time Handle Problem Language Result Execution time Memory
1027585 2024-07-19T07:49:32 Z vjudge1 Trampoline (info1cup20_trampoline) C++17
30 / 100
235 ms 32640 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

void f(){
	#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	//f();

	int n, m, t; cin >> n >> m >> t;
	vector<array<int, 2>> tram(t);
	vector<array<int, 17>> p(t+1);

	for(auto &[i, l]: tram) cin >> i >> l;

	sort(tram.begin(), tram.end());
	vector<array<int, 2>> ol;
	int pos=-1;
	for(int i=t-1; i>=0; i--){

		auto [r, c]=tram[i];

		if(i<t-1&&tram[i+1][0]!=r){
			ol.clear();
			for(int j=i+1; j<t; j++){
				if(tram[j][0]==r+1){
					ol.push_back({tram[j][1], j});
				}
				else break;
			}

			pos=ol.size()-1;
		} 

		while(pos>=0&&ol[pos-1][0]>=c) pos--;
		
		if(pos<0){

			p[i][0]=i;
		}
		else{
			p[i][0]=ol[pos][1];
		}
	}

	for(int l=1; l<17; l++){
		for(int i=0; i<t; i++){
			p[i][l]=p[p[i][l-1]][l-1];
		}
	}

	int q; cin >> q;
	while(q--){ 
		int x, y; cin >> x >> y;
		int pos=lower_bound(tram.begin(), tram.end(), (array<int, 2>){x, y})-tram.begin();
		int ex, ey; cin >> ex >> ey;

		if(ex==x){
			if(y<=ey) cout<<"Yes";
			else cout<<"No";
		}
		else if(ex<x){
			cout<<"No";
		}
		else if(tram.size()==pos) cout<<"No";
		else if(tram[pos][0]!=x) cout<<"No";
		else{
			int dif=ex-x-1;
			for(int j=16; j>=0; j--){
				if((1<<j)<=dif){
					pos=p[pos][j];
					dif-=(1<<j);
				}
			}

			if(tram[pos][0]==ex-1&&tram[pos][1]<=ey){
				cout<<"Yes";
			}
			else cout<<"No";

		}

		cout<<"\n";
	}
}

Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:73:22: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   73 |   else if(tram.size()==pos) cout<<"No";
      |           ~~~~~~~~~~~^~~~~
trampoline.cpp: In function 'void f()':
trampoline.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  freopen("in.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:8:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  freopen("out.txt", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1624 KB expected NO, found YES [39th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 60 ms 30200 KB expected NO, found YES [22nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 150 ms 32640 KB 200000 token(s): yes count is 110486, no count is 89514
2 Correct 165 ms 32208 KB 200000 token(s): yes count is 114664, no count is 85336
3 Correct 154 ms 31092 KB 200000 token(s): yes count is 86232, no count is 113768
4 Correct 146 ms 30712 KB 200000 token(s): yes count is 94603, no count is 105397
5 Correct 157 ms 30804 KB 200000 token(s): yes count is 94148, no count is 105852
6 Correct 145 ms 30804 KB 200000 token(s): yes count is 97163, no count is 102837
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1116 KB 5000 token(s): yes count is 3238, no count is 1762
2 Correct 3 ms 1116 KB 5000 token(s): yes count is 3837, no count is 1163
3 Correct 3 ms 1116 KB 5000 token(s): yes count is 4104, no count is 896
4 Correct 3 ms 1116 KB 5000 token(s): yes count is 3934, no count is 1066
5 Correct 3 ms 1116 KB 5000 token(s): yes count is 3384, no count is 1616
6 Correct 4 ms 1116 KB 5000 token(s): yes count is 3390, no count is 1610
# Verdict Execution time Memory Grader output
1 Correct 179 ms 30728 KB 200000 token(s): yes count is 171404, no count is 28596
2 Correct 163 ms 30804 KB 200000 token(s): yes count is 161254, no count is 38746
3 Correct 161 ms 31188 KB 200000 token(s): yes count is 117455, no count is 82545
4 Incorrect 235 ms 30800 KB expected YES, found NO [4th token]
5 Halted 0 ms 0 KB -