Submission #523721

# Submission time Handle Problem Language Result Execution time Memory
523721 2022-02-08T05:05:32 Z iskhakkutbilim Trampoline (info1cup20_trampoline) C++14
0 / 100
2000 ms 19264 KB
// Author: Tazhibaev Iskhak
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef tree<pair<int, int> ,null_type,less< pair<int, int> >,rb_tree_tag,
	tree_order_statistics_node_update> ordered_set;
const long double pi = acos((long double) - 1.0);
const double eps = (double)1e-9;
const int INF = 1e9 + 7;
    #define ff         first
    #define ss         second
    #define ll         long long
    #define ld		   long double
    #define pb         push_back
void usaco( string filename){
  freopen((filename+".in").c_str(), "r", stdin);
  freopen((filename+".out").c_str(), "w", stdout);
}
int r, c, n;

int in(int i, int j){
	if(i >= 1 and i <= r and j >= 1 and j <= c) return 1;
			return 0;
}


main(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(nullptr); cout.tie(nullptr);
	 cin >> r >> c >> n;
	 set< pair<int, int> > st;
	 set< pair<int, int> > idx;
	 for(int i = 0;i < n; i++){
	 	int x, y; 
	 	cin >> x >> y;
	 	st.insert({x, y});
	 	idx.insert({y, x});
	 }		 
     int T;
     cin >> T;
     while(T--){
     	pair<int, int> start;
     	cin >> start.ff >> start.ss;
     	pair<int, int> end;
     	cin >> end.ff >> end.ss;
     	
     	if(end.ff == start.ff and end.ss >= end.ff){
     		cout << "Yes" << "\n";
     		continue;
     	}else if(end.ff < start.ff ){
     		cout << "No" << "\n";
     		continue;
     	}else if(end.ss < start.ss){
     		cout << "No" << "\n";
     		continue;
     	}
     	int L = distance(st.begin(), st.upper_bound(start));
     	int R = distance(st.begin(), st.upper_bound(end));
     	int l = distance(idx.begin(), idx.upper_bound({start.ss, start.ff}));
     	int r = distance(idx.begin(), idx.upper_bound({end.ss, end.ff}));
     	// cout << min(R - L, r - l) << " ";
     	R--;
     	L--;
     	
     	int x = min(R - L, r - l);
     	if(x >= end.ff - start.ff){  
     		cout << "Yes";
     	}else cout << "No";
     	cout << "\n";
     }
    return 0;
}

Compilation message

trampoline.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main(){
      | ^~~~
trampoline.cpp: In function 'void usaco(std::string)':
trampoline.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen((filename+".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
trampoline.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   freopen((filename+".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 1112 KB expected NO, found YES [2nd token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 18988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2082 ms 18980 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 527 ms 776 KB expected NO, found YES [59th token]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2033 ms 19264 KB Time limit exceeded
2 Halted 0 ms 0 KB -