Submission #365977

# Submission time Handle Problem Language Result Execution time Memory
365977 2021-02-12T15:47:56 Z fadi57 Trampoline (info1cup20_trampoline) C++14
43 / 100
2000 ms 338064 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mx=5009;
const int mod= 1e9+7 ;
const ll inf=1e12+4;

//***while there is life there is hope


int r,c,n;

int main() {



	 //ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	 cin>>r>>c>>n;
	 int rr[n];
	 int cc[n];
	map<int,vector<int>>row;
	 for(int i=0;i<n;i++){


        cin>>rr[i]>>cc[i];
        row[rr[i]].push_back(cc[i]);
	 }for(ll i=1;i<=r;i++){

	 sort(row[i].begin(),row[i].end());
	 }
	 int t;


	 cin>>t;



while(t--){
    ll x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    int ans=0;
    if(x1<=x2&&y1<=y2){
if(x2-x1==1){

     for(int i=0;i<n;i++){


       if(rr[i]==x1&&cc[i]>=y1&&cc[i]<=y2){
        ans=1;
       }
	 }



}else{

        while(x1<x2){

            if(row[x1].empty()){break;}
            ll nxt=lower_bound(row[x1].begin(),row[x1].end(),y1)-row[x1].begin();
            if(nxt==row[x1].size()||row[x1][nxt]>y2){break;}
y1=row[x1][nxt];

    //cout<<"test :"<<x1<<" "<<row[x1][nxt]<<endl;
 x1++;
        }

         if(x1==x2){ans=1;}
        }






    }if(ans){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}




}
}










Compilation message

trampoline.cpp: In function 'int main()':
trampoline.cpp:63:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |             if(nxt==row[x1].size()||row[x1][nxt]>y2){break;}
      |                ~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 492 KB 200 token(s): yes count is 21, no count is 179
2 Correct 7 ms 492 KB 200 token(s): yes count is 70, no count is 130
3 Correct 6 ms 492 KB 197 token(s): yes count is 25, no count is 172
# Verdict Execution time Memory Grader output
1 Correct 212 ms 3628 KB 4000 token(s): yes count is 99, no count is 3901
2 Correct 222 ms 3808 KB 4000 token(s): yes count is 91, no count is 3909
3 Correct 570 ms 3308 KB 4000 token(s): yes count is 4000, no count is 0
4 Correct 916 ms 3768 KB 4000 token(s): yes count is 1991, no count is 2009
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 337288 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 337776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2114 ms 338064 KB Time limit exceeded
2 Halted 0 ms 0 KB -