more code
This commit is contained in:
parent
7aacde99f4
commit
742bf851a9
149 changed files with 7065 additions and 0 deletions
2
codeforces/974/.clang-format
Normal file
2
codeforces/974/.clang-format
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
BasedOnStyle: Google
|
||||
AllowShortFunctionsOnASingleLine: Empty
|
||||
67
codeforces/974/a.cc
Normal file
67
codeforces/974/a.cc
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename T>
|
||||
T MAX() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MIN() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define ld long double
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
static constexpr int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
int n, k;
|
||||
cin >> n >> k;
|
||||
vec<int> people(n);
|
||||
for (auto &e : people) cin >> e;
|
||||
int ans = 0, robin = 0;
|
||||
for (auto amount : people) {
|
||||
if (amount >= k)
|
||||
robin += amount;
|
||||
else if (robin > 0 && amount == 0) {
|
||||
--robin;
|
||||
++ans;
|
||||
}
|
||||
}
|
||||
cout << ans << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
codeforces/974/a.debug
Executable file
BIN
codeforces/974/a.debug
Executable file
Binary file not shown.
9
codeforces/974/a.in
Normal file
9
codeforces/974/a.in
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
4
|
||||
2 2
|
||||
2 0
|
||||
3 2
|
||||
3 0 0
|
||||
6 2
|
||||
0 3 0 0 0 0
|
||||
2 5
|
||||
5 4
|
||||
4
codeforces/974/a.out
Normal file
4
codeforces/974/a.out
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
0
|
||||
112
codeforces/974/b.cc
Normal file
112
codeforces/974/b.cc
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename... Args>
|
||||
void print(std::string const &str, Args &&...args) {
|
||||
std::cout << std::vformat(
|
||||
str,
|
||||
// make_format_args binds arguments to const
|
||||
str, std::make_format_args(static_cast<Args const &>(args)...));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void print(T const &t) {
|
||||
std::cout << t;
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void print(T const &t) {
|
||||
if constexpr (std::is_convertible_v<T, char const *>) {
|
||||
std::cout << t << '\n';
|
||||
} else {
|
||||
for (auto const &e : t) {
|
||||
std::cout << e << ' ';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void println(std::string const &str, Args &&...args) {
|
||||
print(str, std::forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void println(T const &t) {
|
||||
print("{}\n", t);
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void println(T const &t) {
|
||||
cout << t << '\n';
|
||||
}
|
||||
|
||||
void println() {
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MAX() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MIN() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define ld long double
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
static constexpr int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
int n, k;
|
||||
cin >> n >> k;
|
||||
|
||||
int overlaps = k - 1;
|
||||
|
||||
if (n & 1) {
|
||||
// need odd # odds in overlaps
|
||||
int odd_count = floor(overlaps / 2);
|
||||
|
||||
cout << (odd_count & 1 ? "YES" : "NO");
|
||||
} else {
|
||||
int odd_count = ceil(overlaps / 2);
|
||||
cout << (odd_count & 1 ? "NO" : "YES");
|
||||
}
|
||||
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
int t;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
BIN
codeforces/974/b.debug
Executable file
BIN
codeforces/974/b.debug
Executable file
Binary file not shown.
6
codeforces/974/b.in
Normal file
6
codeforces/974/b.in
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
5
|
||||
1 1
|
||||
2 1
|
||||
2 2
|
||||
3 2
|
||||
4 4
|
||||
5
codeforces/974/b.out
Normal file
5
codeforces/974/b.out
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
NO
|
||||
YES
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
114
codeforces/974/c.cc
Normal file
114
codeforces/974/c.cc
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename... Args>
|
||||
void print(std::string const &str, Args &&...args) {
|
||||
std::cout << std::vformat(
|
||||
str,
|
||||
// make_format_args binds arguments to const
|
||||
str, std::make_format_args(static_cast<Args const &>(args)...));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void print(T const &t) {
|
||||
std::cout << t;
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void print(T const &t) {
|
||||
if constexpr (std::is_convertible_v<T, char const *>) {
|
||||
std::cout << t << '\n';
|
||||
} else {
|
||||
for (auto const &e : t) {
|
||||
std::cout << e << ' ';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void println(std::string const &str, Args &&...args) {
|
||||
print(str, std::forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void println(T const &t) {
|
||||
print("{}\n", t);
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void println(T const &t) {
|
||||
cout << t << '\n';
|
||||
}
|
||||
|
||||
void println() {
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MAX() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MIN() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define ld long double
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
static constexpr int MOD = 1e9 + 7;
|
||||
|
||||
void solve() {
|
||||
ll n;
|
||||
cin >> n;
|
||||
vec<int> people(n);
|
||||
ll total = 0;
|
||||
for (auto &e : people) {
|
||||
cin >> e;
|
||||
total += e;
|
||||
};
|
||||
|
||||
sort(all(people));
|
||||
|
||||
if (n >= 3) {
|
||||
cout << max(static_cast<ll>(0), 1 + people[n / 2] * 2 * n - total);
|
||||
} else
|
||||
cout << -1;
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
13
codeforces/974/c.in
Normal file
13
codeforces/974/c.in
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
6
|
||||
1
|
||||
2
|
||||
2
|
||||
2 19
|
||||
3
|
||||
1 3 20
|
||||
4
|
||||
1 2 3 4
|
||||
5
|
||||
1 2 3 4 5
|
||||
6
|
||||
1 2 1 1 1 25
|
||||
6
codeforces/974/c.out
Normal file
6
codeforces/974/c.out
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-1
|
||||
-1
|
||||
0
|
||||
15
|
||||
16
|
||||
0
|
||||
5
codeforces/974/compile_flags.txt
Normal file
5
codeforces/974/compile_flags.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-std=c++20
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wshadow
|
||||
-DLOCAL
|
||||
130
codeforces/974/d.cc
Normal file
130
codeforces/974/d.cc
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename... Args>
|
||||
void print(std::string const &str, Args &&...args) {
|
||||
std::cout << std::vformat(
|
||||
str,
|
||||
// make_format_args binds arguments to const
|
||||
str, std::make_format_args(static_cast<Args const &>(args)...));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void print(T const &t) {
|
||||
std::cout << t;
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void print(T const &t) {
|
||||
if constexpr (std::is_convertible_v<T, char const *>) {
|
||||
std::cout << t << '\n';
|
||||
} else {
|
||||
for (auto const &e : t) {
|
||||
std::cout << e << ' ';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void println(std::string const &str, Args &&...args) {
|
||||
print(str, std::forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void println(T const &t) {
|
||||
print("{}\n", t);
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void println(T const &t) {
|
||||
cout << t << '\n';
|
||||
}
|
||||
|
||||
void println() {
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MAX() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MIN() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define ld long double
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
static constexpr int MOD = 1e9 + 7;
|
||||
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
void solve() {
|
||||
int n, d, k;
|
||||
cin >> n >> d >> k;
|
||||
vec<int> start(n + 1);
|
||||
vec<int> end(n + 1);
|
||||
while (k--) {
|
||||
int l, r;
|
||||
cin >> l >> r;
|
||||
++start[l];
|
||||
++end[r];
|
||||
}
|
||||
|
||||
// prefix
|
||||
FOR(i, 1, n + 1) {
|
||||
start[i] += start[i - 1];
|
||||
end[i] += end[i - 1];
|
||||
}
|
||||
|
||||
int brother = MIN<int>(), mother = MAX<int>();
|
||||
int brother_day = 0, mother_day = 0;
|
||||
FOR(i, 0, n - d + 1) {
|
||||
if (start[i + d] - end[i] > brother) {
|
||||
brother = start[i + d] - end[i];
|
||||
brother_day = i;
|
||||
}
|
||||
if (start[i + d] - end[i] < mother) {
|
||||
mother = start[i + d] - end[i];
|
||||
mother_day = i;
|
||||
}
|
||||
}
|
||||
cout << (brother_day + 1) << ' ' << (mother_day + 1) << '\n';
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
20
codeforces/974/d.in
Normal file
20
codeforces/974/d.in
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
6
|
||||
2 1 1
|
||||
1 2
|
||||
4 1 2
|
||||
1 2
|
||||
2 4
|
||||
7 2 3
|
||||
1 2
|
||||
1 3
|
||||
6 7
|
||||
5 1 2
|
||||
1 2
|
||||
3 5
|
||||
9 2 1
|
||||
2 8
|
||||
9 2 4
|
||||
7 9
|
||||
4 8
|
||||
1 3
|
||||
2 3
|
||||
6
codeforces/974/d.out
Normal file
6
codeforces/974/d.out
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
1 1
|
||||
2 1
|
||||
1 4
|
||||
1 1
|
||||
1 1
|
||||
3 4
|
||||
229
codeforces/974/h.cc
Normal file
229
codeforces/974/h.cc
Normal file
|
|
@ -0,0 +1,229 @@
|
|||
#include <bits/stdc++.h>
|
||||
|
||||
// https://codeforces.com/blog/entry/96344
|
||||
|
||||
#pragma GCC optimize("O2,unroll-loops")
|
||||
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
|
||||
|
||||
using namespace std;
|
||||
|
||||
template <typename... Args>
|
||||
void print(std::string const &str, Args &&...args) {
|
||||
std::cout << std::vformat(
|
||||
str,
|
||||
// make_format_args binds arguments to const
|
||||
str, std::make_format_args(static_cast<Args const &>(args)...));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void print(T const &t) {
|
||||
std::cout << t;
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void print(T const &t) {
|
||||
if constexpr (std::is_convertible_v<T, char const *>) {
|
||||
std::cout << t << '\n';
|
||||
} else {
|
||||
for (auto const &e : t) {
|
||||
std::cout << e << ' ';
|
||||
}
|
||||
std::cout << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void println(std::string const &str, Args &&...args) {
|
||||
print(str, std::forward<Args>(args)...);
|
||||
cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void println(T const &t) {
|
||||
print("{}\n", t);
|
||||
}
|
||||
|
||||
template <std::ranges::range T>
|
||||
void println(T const &t) {
|
||||
cout << t << '\n';
|
||||
}
|
||||
|
||||
void println() {
|
||||
std::cout << '\n';
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MAX() {
|
||||
return std::numeric_limits<T>::max();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T MIN() {
|
||||
return std::numeric_limits<T>::min();
|
||||
}
|
||||
|
||||
#define ff first
|
||||
#define ss second
|
||||
#define eb emplace_back
|
||||
#define ll long long
|
||||
#define ld long double
|
||||
#define vec vector
|
||||
|
||||
#define all(x) (x).begin(), (x).end()
|
||||
#define rall(x) (r).rbegin(), (x).rend()
|
||||
#define sz(x) static_cast<int>((x).size())
|
||||
|
||||
#ifdef LOCAL
|
||||
#define dbg(x) cout << __LINE__ << ": " << #x << "=<" << (x) << ">\n";
|
||||
#else
|
||||
#define dbg(x)
|
||||
#endif
|
||||
|
||||
#define FOR(a, b, c) for (int a = b; a < c; ++a)
|
||||
|
||||
static constexpr int MOD = 1e9 + 7;
|
||||
|
||||
#include <ext/pb_ds/assoc_container.hpp>
|
||||
#include <ext/pb_ds/tree_policy.hpp>
|
||||
|
||||
using namespace __gnu_pbds;
|
||||
|
||||
// https://mirror.codeforces.com/blog/entry/124683
|
||||
|
||||
namespace hashing {
|
||||
using i64 = std::int64_t;
|
||||
using u64 = std::uint64_t;
|
||||
static const u64 FIXED_RANDOM =
|
||||
std::chrono::steady_clock::now().time_since_epoch().count();
|
||||
|
||||
#if USE_AES
|
||||
std::mt19937 rd(FIXED_RANDOM);
|
||||
const __m128i KEY1{(i64)rd(), (i64)rd()};
|
||||
const __m128i KEY2{(i64)rd(), (i64)rd()};
|
||||
#endif
|
||||
|
||||
template <class T, class D = void>
|
||||
struct custom_hash {};
|
||||
|
||||
template <class T>
|
||||
inline void hash_combine(u64 &seed, T const &v) {
|
||||
custom_hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b97f4a7c15 + (seed << 12) + (seed >> 4);
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T,
|
||||
typename std::enable_if<std::is_integral<T>::value>::type> {
|
||||
u64 operator()(T _x) const {
|
||||
u64 x = _x;
|
||||
#if USE_AES
|
||||
__m128i m{i64(u64(x) * 0xbf58476d1ce4e5b9u64), (i64)FIXED_RANDOM};
|
||||
__m128i y = _mm_aesenc_si128(m, KEY1);
|
||||
__m128i z = _mm_aesenc_si128(y, KEY2);
|
||||
return z[0];
|
||||
#else
|
||||
x += 0x9e3779b97f4a7c15 + FIXED_RANDOM;
|
||||
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
|
||||
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
|
||||
return x ^ (x >> 31);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct custom_hash<T, std::void_t<decltype(std::begin(std::declval<T>()))>> {
|
||||
u64 operator()(T const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
for (auto &x : a) hash_combine(value, x);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class... T>
|
||||
struct custom_hash<std::tuple<T...>> {
|
||||
u64 operator()(const std::tuple<T...> &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
std::apply([&value](T const &...args) { (hash_combine(value, args), ...); },
|
||||
a);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
struct custom_hash<std::pair<T, U>> {
|
||||
u64 operator()(std::pair<T, U> const &a) const {
|
||||
u64 value = FIXED_RANDOM;
|
||||
hash_combine(value, a.first);
|
||||
hash_combine(value, a.second);
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}; // namespace hashing
|
||||
|
||||
#ifdef PB_DS_ASSOC_CNTNR_HPP
|
||||
template <class Key, class Value>
|
||||
using hashmap = gp_hash_table<
|
||||
Key, Value, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
template <class Key>
|
||||
using hashset = gp_hash_table<
|
||||
Key, null_type, hashing::custom_hash<Key>, std::equal_to<Key>,
|
||||
direct_mask_range_hashing<>, linear_probe_fn<>,
|
||||
hash_standard_resize_policy<hash_exponential_size_policy<>,
|
||||
hash_load_check_resize_trigger<>, true>>;
|
||||
|
||||
#endif
|
||||
#ifdef PB_DS_TREE_POLICY_HPP
|
||||
template <typename T>
|
||||
using multiset = tree<T, null_type, std::less_equal<T>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
template <class Key, class Value = null_type>
|
||||
using rbtree = tree<Key, Value, std::less<Key>, rb_tree_tag,
|
||||
tree_order_statistics_node_update>;
|
||||
#endif
|
||||
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<> distrib(0, MAX<int>());
|
||||
|
||||
void solve() {
|
||||
int n, q;
|
||||
cin >> n >> q;
|
||||
|
||||
vector<int> prefix_hash_xor(n);
|
||||
// map index in a -> hash
|
||||
hashmap<int, int> hm;
|
||||
|
||||
FOR(i, 0, n) {
|
||||
cin >> prefix_hash_xor[i];
|
||||
prefix_hash_xor[i] ^= (i ? prefix_hash_xor[i - 1] : 0);
|
||||
}
|
||||
|
||||
while (q--) {
|
||||
int l, r;
|
||||
cin >> l >> r;
|
||||
|
||||
--l;
|
||||
--r;
|
||||
|
||||
bool even_each =
|
||||
(prefix_hash_xor[r] ^ (l ? prefix_hash_xor[l - 1] : 0)) == 0;
|
||||
|
||||
cout << (even_each ? "YES" : "NO") << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin.tie(nullptr)->sync_with_stdio(false);
|
||||
|
||||
int t = 1;
|
||||
cin >> t;
|
||||
|
||||
while (t--) {
|
||||
solve();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
11
codeforces/974/h.in
Normal file
11
codeforces/974/h.in
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
2
|
||||
3 3
|
||||
1 2 2
|
||||
1 2
|
||||
1 3
|
||||
2 3
|
||||
5 3
|
||||
2 1 2 1 1
|
||||
1 2
|
||||
1 3
|
||||
4 5
|
||||
6
codeforces/974/h.out
Normal file
6
codeforces/974/h.out
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
Loading…
Add table
Add a link
Reference in a new issue