Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- pair<int, int> a[200001];
- int v[200001], x[200001];
- int cBin(int v[], int st, int dr, int e)
- {
- if (st > dr)
- {
- if (v[st] == e)
- {
- return 1;
- }
- return 0;
- }
- else
- {
- int m = (st + dr) / 2;
- if (e == v[m])
- {
- return
- }
- }
- }
- int main()
- {
- int n, t, x, y;
- cin >> n >> t;
- for (int i = 1; i <= n; i++)
- {
- cin >> v[i];
- }
- for (int i = 1; i <= t; i++)
- {
- cin >> a[i].first >> a[i].second;
- }
- for (int i = 1; i <= t; i++)
- {
- for (int h = 1; h <= n; h++)
- {
- for (int k = 1; k <= a[i].second - a[i].first; k++)
- {
- for (int j = a[i].first; j <= a[i].second; j++)
- {
- x[k] = j;
- }
- }
- cout << cBin(x, 1, t, v[h]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement