Advertisement
ahmed_aly

Untitled

Apr 30th, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. int main() {
  2.     scanf("%d%d%d%d", &I, &J, &K, &T);
  3.     v.resize(I + 1);
  4.     rep(i,K) {
  5.         scanf("%d%d", &ii, &jj);
  6.         v[ii].pb(jj);
  7.     }
  8.     rep2(i,1,I+1) {
  9.         sort(all(v[i]));
  10.         acc[i] = acc[i - 1] + sz(v[i]);
  11.     }
  12.     string s[3] = { "Carrots", "Kiwis", "Grapes" };
  13.     rep(i,T) {
  14.         scanf("%d%d", &ii, &jj);
  15.         int ind = lower_bound(all(v[ii]),jj) - v[ii].begin();
  16.         if (ind < sz(v[ii]) && v[ii][ind] == jj) {
  17.             printf("Waste\n");
  18.             continue;
  19.         }
  20.         ind += acc[ii - 1];
  21.         int tot = (ii - 1) * J + jj;
  22.         tot -= ind;
  23.         tot--;
  24.         tot %= 3;
  25.         printf("%s\n", s[tot].c_str());
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement