QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133315 | #4269. Rainy Markets | HunterXD# | 0 | 1ms | 3576kb | C++14 | 1.3kb | 2023-08-01 23:31:58 | 2024-07-04 01:08:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define all(x) x.begin(), x.end()
const char nd = '\n';
ll n, k, q;
vl a;
bool check(ll l, ll r) {
vvl graph(k + 1, vl());
vl counter(k + 1, 0);
bool step = true;
for (ll i = l + 1; i <= r; i++) {
if (step) {
graph[a[i]].push_back(a[i - 1]);
counter[a[i - 1]]++;
} else {
graph[a[i - 1]].push_back(a[i]);
counter[a[i]]++;
}
step = !step;
}
queue<ll> release;
for (ll i = 1; i <= k; i++) {
if (!counter[i]) release.push(i);
}
ll temp, res = 0;
while (!release.empty()) {
temp = release.front(), release.pop();
res++;
for (auto v : graph[temp]) {
counter[v]--;
if (!counter[v]) release.push(v);
}
}
return (res == k);
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//
cin >> n >> k >> q;
a.resize(n);
for (auto &v : a) cin >> v;
vl best(n, 0);
for (ll i = 0; i < n; i++) best[i] = i;
ll l, r;
for (l = 0; l < n; l++) {
r = max(r, l);
while ((r + 1 < n) && check(l, r + 1)) r++;
best[l] = r;
}
while (q--) {
cin >> l >> r;
l--, r--;
cout << (check(l, r) ? "YES" : "NO") << nd;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3576kb
input:
3 10 15 10 20 20 0 0
output:
YES YES YES YES YES YES YES YES YES YES YES YES YES YES YES
result:
wrong answer read 'YES' but expected 'NO'
Subtask #2:
score: 0
Runtime Error
Test #36:
score: 0
Runtime Error
input:
3 10 15 10 20 20 0 11
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%