Advertisement
GabiZUU

pbinfo 2276

Mar 21st, 2023
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. pair<int, int> a[200001];
  5.  
  6. int v[200001], x[200001];
  7.  
  8. int cBin(int v[], int st, int dr, int e)
  9. {
  10.     if (st > dr)
  11.     {
  12.         if (v[st] == e)
  13.         {
  14.             return 1;
  15.         }
  16.         return 0;
  17.     }
  18.     else
  19.     {
  20.         int m = (st + dr) / 2;
  21.         if (e == v[m])
  22.         {
  23.             return
  24.         }
  25.     }
  26. }
  27.  
  28. int main()
  29. {
  30.     int n, t, x, y;
  31.     cin >> n >> t;
  32.     for (int i = 1; i <= n; i++)
  33.     {
  34.         cin >> v[i];
  35.     }
  36.     for (int i = 1; i <= t; i++)
  37.     {
  38.         cin >> a[i].first >> a[i].second;
  39.     }
  40.     for (int i = 1; i <= t; i++)
  41.     {
  42.         for (int h = 1; h <= n; h++)
  43.         {
  44.             for (int k = 1; k <= a[i].second - a[i].first; k++)
  45.             {
  46.                 for (int j = a[i].first; j <= a[i].second; j++)
  47.                 {
  48.                     x[k] = j;
  49.                 }
  50.             }
  51.             cout << cBin(x, 1, t, v[h]);
  52.         }
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement