Skip to content

Commit 42031b5

Browse files
authoredNov 3, 2023
Create 302A.cc
1 parent 1483071 commit 42031b5

File tree

1 file changed

+129
-0
lines changed

1 file changed

+129
-0
lines changed
 

‎302A.cc

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include <bits/stdc++.h>
2+
#define ll long long int
3+
#define ull unsigned long long int
4+
#define cint const int
5+
#define fo(number1, number2, number3) for (int number1 = number2; number1 < number3; ++number1)
6+
#define rfo(number1, number2, number3) for (int number1 = number2 - 1; number1 >= number3; --number1)
7+
#define pi pair<int, int>
8+
#define vLL vector<ll>
9+
#define vi vector<int>
10+
#define pb push_back
11+
#define ppb pop_back
12+
#define eb emplace_back
13+
#define lbd lower_bound
14+
#define ubd upper_bound
15+
#define mp make_pair
16+
#define cps CLOCKS_PER_SEC
17+
#define decimal(k) fixed << setprecision(k)
18+
#define PI 3.14159265359
19+
#define fastio \
20+
ios_base::sync_with_stdio(false); \
21+
cin.tie(NULL); \
22+
cout.tie(NULL);
23+
#define ff first
24+
#define ss second
25+
#define all(V) (V).begin(), (V).end()
26+
#define alla(a, n) a, a + n
27+
#define sz(v) (ll) v.size()
28+
#define SORT(v) sort(all(v))
29+
#define REV reverse
30+
#define SUM(v) accumulate(v.begin(), v.end(), 0)
31+
#define MAX max_element
32+
#define MIN min_element
33+
#define UNIQUE(v) \
34+
SORT(v); \
35+
v.erase(unique(v.begin(), v.end()), v.end())
36+
#define UNIQUEA(a, n) unique(a, a + n) - a
37+
#define MAXA(a, n) max_element(a, a + n)
38+
#define MINA(a, n) min_element(a, a + n)
39+
#define SORTA(a, n) sort(alla(a, n))
40+
#define REVA(a, n) reverse(alla(a, n))
41+
#define mem1(a) memset(a, -1, sizeof(a));
42+
#define mem0(a) memset(a, 0, sizeof(a));
43+
#define mymax 1000000000000000100
44+
#define mymin -1000000001
45+
#define bitcount __builtin_popcount
46+
#define gcd __gcd
47+
#define MOD (ll)1000000007
48+
#define TEST(t) \
49+
int tc; \
50+
cin >> tc; \
51+
fo(t, 1, tc)
52+
#define VECT(v, n) \
53+
ll n; \
54+
cin >> n; \
55+
vLL v(n); \
56+
fo(i, 0, n - 1) cin >> v[i];
57+
#define NUM(n) \
58+
ll n; \
59+
cin >> n;
60+
#define STRING(s) \
61+
string s; \
62+
cin >> s;
63+
#define TS to_string
64+
#define len(s) (s).length()
65+
#define line cout << "\n";
66+
#define el "\n"
67+
#define vec vector<int>
68+
#define clkstart auto start = high_resolution_clock::now();
69+
#define clkend \
70+
auto stop = high_resolution_clock::now(); \
71+
auto duration = duration_cast<microseconds>(stop - start);
72+
#define TIME \
73+
line; \
74+
line; \
75+
cout << "Time taken by function: " << duration.count() / 1e6 << " seconds" << endl;
76+
#define open {
77+
#define close }
78+
#define goog(tno) cout << "Case #" << tno << ": "
79+
#define deb(x) cout << #x << " = " << x << el;
80+
#define deb2(x, y) cout << #x << " = " << x << " : " << #y << " = " << y << el;
81+
// #ifndef SEGMENTTREE_H
82+
#define SEGMENTTREE_H
83+
#define left(i) (2 * i + 1)
84+
#define right(i) (2 * i + 2)
85+
#define parent(i) ((i - 1) / 2)
86+
using namespace std;
87+
// bool is_perfect_square(ll n) {
88+
// if (n < 0)
89+
// return false;
90+
// ll root(round(sqrt(n)));
91+
// return n == root * root;
92+
// }
93+
// bool isPrime(ll N) { // a good enough deterministic prime tester
94+
// if (N <= _sieve_size) return bs[N]; // O(1) for small primes
95+
// for (int i = 0; i < (int)primes.size(); i++)
96+
// if (N % primes[i] == 0) return false;
97+
// return true; // it takes longer time if N is a large prime!
98+
// }
99+
int main()
100+
{
101+
fastio
102+
ll n,
103+
m, c1 = 0, c0 = 0;
104+
cin >> n >> m;
105+
vLL v(n);
106+
for (auto &i : v)
107+
{
108+
cin >> i;
109+
if (i == 1)
110+
c1++;
111+
else
112+
c0++;
113+
}
114+
while (m--)
115+
{
116+
ll a, b;
117+
cin >> a >> b;
118+
if (a == b || c1 == 0 || c0 == 0)
119+
cout << "0" << endl;
120+
else if ((b - a + 1) % 2 != 0)
121+
cout << "0" << endl;
122+
else if ((b - a + 1) <= 2 * min(c1, c0))
123+
{
124+
cout << "1" << endl;
125+
}
126+
else
127+
cout << "0" << endl;
128+
}
129+
}

0 commit comments

Comments
 (0)
Please sign in to comment.