SHARE
TWEET

Untitled

a guest Jul 17th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, m, k, t;
  4. int kstill = 0;
  5. int t1, t2,t3;
  6. string crops[3] = {"Carrots","kiwis","Grapes"};
  7. int idl(int t1h,int t2h)
  8. {
  9.     int ret;
  10.     ret = ((t1h)*m)+t2h;
  11.     return ret;
  12. }
  13. bool valid(int id,int value,vector<int> &gap){
  14.     return gap[value]<= id;
  15. }
  16. int waste(int id,vector<int> &gap )
  17. {
  18.     int minx = 0,maxx = gap.size()-1,mid,ans;
  19.     while(minx<=maxx){
  20.         mid = (minx+maxx)/2;
  21.         if(valid(id,mid,gap)){
  22.             maxx = mid-1;
  23.         }else{
  24.             minx = mid+1;
  25.             ans = mid;
  26.         }
  27.     }
  28.     if(gap[ans]==id){
  29.         return -1;
  30.     }
  31.     return ans;
  32. }
  33. int main()
  34. {
  35.     vector<int> gap;
  36.     cin>>n>>m>>k>>t;
  37.     gap[0] = 0;
  38.     for(int i = 0 ; i<k ; i++)
  39.     {
  40.         cin>>t1>>t2;
  41.         kstill += 1;
  42.         gap[kstill] = idl(t1,t2);
  43.     }
  44.     for(int i = 0 ; i<t ; i++)
  45.     {
  46.         cin>>t1>>t2;
  47.         int id = idl(t1,t2);
  48.         int w = waste(id,gap);
  49.         if(w==-1){
  50.             cout<<"Waste\n";
  51.         }else{
  52.             id -=w;
  53.             cout<<crops[id%3]<<"\n";
  54.         }
  55.  
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top