Advertisement
Emiliatan

e095 - 2

Mar 7th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. /* e095              */
  2. /* AC (0.3s, 11.2MB) */
  3. #include <cstdio>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. const int MAXQ = 100000;
  9. int *arr, query[MAXQ], ans[MAXQ], buf[MAXQ]{};
  10. int n, m, len, q;
  11.  
  12. int main()
  13. {
  14.     scanf("%d %d", &n, &m);
  15.  
  16.     arr = new int [len = n * m];
  17.     for(int i = 0; i < len; i++)
  18.         scanf("%d", arr + i);
  19.  
  20.     scanf("%d", &q);
  21.     for(int i = 0; i < q; *(query + i) = *(ans + i), i++)
  22.         scanf("%d", ans + i);
  23.  
  24.     sort(ans, ans + q);
  25.     for(int i = 0, x = 0; i < len; x++, i++)
  26.         if(ans[x = lower_bound(ans, ans + q, *(arr + i)) - ans] == *(arr + i)) buf[x] = i + 1;
  27.  
  28.     for(int i = 0, x; i < q; putchar('\n'), i++)
  29.         if(buf[(x = lower_bound(ans, ans + q, *(query + i)) - ans)] != 0)
  30.             printf("yes [%d, %d]", (buf[x] - 1) / m + 1, (buf[x] - 1) % m + 1);
  31.         else putchar('n'),putchar('o');
  32.  
  33.     delete arr;
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement