Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, m, k, t;
- int kstill = 0;
- int t1, t2,t3;
- string crops[3] = {"Carrots","kiwis","Grapes"};
- int idl(int t1h,int t2h)
- {
- int ret;
- ret = ((t1h)*m)+t2h;
- return ret;
- }
- bool valid(int id,int value,vector<int> &gap){
- return gap[value]<= id;
- }
- int waste(int id,vector<int> &gap )
- {
- int minx = 0,maxx = gap.size()-1,mid,ans;
- while(minx<=maxx){
- mid = (minx+maxx)/2;
- if(valid(id,mid,gap)){
- maxx = mid-1;
- }else{
- minx = mid+1;
- ans = mid;
- }
- }
- if(gap[ans]==id){
- return -1;
- }
- return ans;
- }
- int main()
- {
- vector<int> gap;
- cin>>n>>m>>k>>t;
- gap[0] = 0;
- for(int i = 0 ; i<k ; i++)
- {
- cin>>t1>>t2;
- kstill += 1;
- gap[kstill] = idl(t1,t2);
- }
- for(int i = 0 ; i<t ; i++)
- {
- cin>>t1>>t2;
- int id = idl(t1,t2);
- int w = waste(id,gap);
- if(w==-1){
- cout<<"Waste\n";
- }else{
- id -=w;
- cout<<crops[id%3]<<"\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement