Flickyyy

B-B'4

Aug 30th, 2022
830
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define all(a) a.begin(), a.end()
  4. #define forn(i, a, b) for (ll i = a; i < b; i++)
  5. #define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr)
  6. using ll = long long;
  7.  
  8. auto getWin(ll steps) {
  9.     return steps % 2 == 0 ? "First" : "Second";
  10. }
  11.  
  12. int main() {
  13.     FAST;
  14.     int n; cin >> n;
  15.     vector<ll> vec(n);
  16.     for (auto& e: vec) cin >> e;
  17.     vector<int> pref1(n + 1);
  18.     for (int i = 1; i < n + 1; i++) {
  19.         pref1[i] = pref1[i - 1];
  20.         if (vec[i] == 1) pref1[i] += 1;
  21.     }
  22.     int q; cin >> q;
  23.     while (q--) {
  24.         int l, r;
  25.         cin >> l >> r;
  26.         int cnt1 = pref1[r] - pref1[l - 1];
  27.  
  28.         bool eq = true;
  29.         forn(i, l, r) {
  30.             if (vec[i - 1] != vec[i]) eq = false;
  31.             //Я ТУТ ОЖИДАЛ TL ЛОЛ
  32.         }
  33.         if (l == r or eq) {
  34.             if (vec[l - 1] == 1) cout << 2;
  35.             else cout << 1;
  36.             cout << endl;
  37.             continue;
  38.         }
  39.         cout << 1 << endl;
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment