Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define all(a) a.begin(), a.end()
- #define forn(i, a, b) for (ll i = a; i < b; i++)
- #define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr)
- using ll = long long;
- auto getWin(ll steps) {
- return steps % 2 == 0 ? "First" : "Second";
- }
- int main() {
- FAST;
- int n; cin >> n;
- vector<ll> vec(n);
- for (auto& e: vec) cin >> e;
- vector<int> pref1(n + 1);
- for (int i = 1; i < n + 1; i++) {
- pref1[i] = pref1[i - 1];
- if (vec[i] == 1) pref1[i] += 1;
- }
- int q; cin >> q;
- while (q--) {
- int l, r;
- cin >> l >> r;
- int cnt1 = pref1[r] - pref1[l - 1];
- bool eq = true;
- forn(i, l, r) {
- if (vec[i - 1] != vec[i]) eq = false;
- //Я ТУТ ОЖИДАЛ TL ЛОЛ
- }
- if (l == r or eq) {
- if (vec[l - 1] == 1) cout << 2;
- else cout << 1;
- cout << endl;
- continue;
- }
- cout << 1 << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment