8660 | 2024-01-25 01:09:04 | renn | Kutyavetélkedő | cpp17 | Wrong answer 34/100 | 108ms | 42276 KiB |
#include <bits/stdc++.h>
using namespace std;
inline bool cnt(unordered_set<int> &x, int &n) {
return x.find(n) != x.end();
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, k, m, a, b;
cin >> n >> k;
vector<int> feladatok(n), legjobb(n+2, -1);
vector<unordered_set<int>> szabalyok(k+1);
for(auto &x : feladatok) { cin >> x; x--; }
if(feladatok[0] == k && feladatok[1] == k) {
cout << "0\n";
exit(0);
}
feladatok.insert(feladatok.end(), {-1, -1});
cin >> m;
while(m--) {
cin >> a >> b;
a--; b--;
if(a == k || b == k) continue;
szabalyok[a].insert(b);
}
legjobb[feladatok[0] == k] = 1;
for(int i = 0, j = (feladatok[0] == k); i < n; i++) {
if(j == 2) {
cout << "0\n";
exit(0);
}
if(legjobb[i] == -1) {
j++;
continue;
}
j = 0;
if(cnt(szabalyok[feladatok[i]], feladatok[i+1]))
legjobb[i+1] = max(legjobb[i+1], legjobb[i]+1);
if(cnt(szabalyok[feladatok[i]], feladatok[i+2]))
legjobb[i+2] = max(legjobb[i+2], legjobb[i]+1);
}
cout << max(0, max(legjobb[n-1], legjobb[n-2]));
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Accepted | 3ms | 2244 KiB | ||||
4 | Accepted | 2ms | 2468 KiB | ||||
5 | Accepted | 2ms | 2312 KiB | ||||
6 | Wrong answer | 3ms | 2552 KiB | ||||
7 | Accepted | 18ms | 6980 KiB | ||||
8 | Accepted | 25ms | 7248 KiB | ||||
9 | Accepted | 25ms | 7528 KiB | ||||
subtask3 | 0/19 | ||||||
10 | Wrong answer | 3ms | 3088 KiB | ||||
11 | Wrong answer | 3ms | 3324 KiB | ||||
12 | Accepted | 2ms | 3332 KiB | ||||
13 | Accepted | 3ms | 3332 KiB | ||||
14 | Accepted | 2ms | 3212 KiB | ||||
15 | Wrong answer | 3ms | 3212 KiB | ||||
16 | Accepted | 2ms | 3280 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Accepted | 3ms | 3732 KiB | ||||
18 | Accepted | 4ms | 3876 KiB | ||||
19 | Accepted | 4ms | 4136 KiB | ||||
20 | Accepted | 4ms | 4140 KiB | ||||
21 | Accepted | 6ms | 4372 KiB | ||||
22 | Accepted | 6ms | 4400 KiB | ||||
subtask5 | 0/32 | ||||||
23 | Wrong answer | 32ms | 12048 KiB | ||||
24 | Accepted | 48ms | 15236 KiB | ||||
25 | Accepted | 52ms | 18124 KiB | ||||
26 | Wrong answer | 43ms | 20748 KiB | ||||
27 | Accepted | 57ms | 22720 KiB | ||||
28 | Wrong answer | 67ms | 18048 KiB | ||||
29 | Wrong answer | 93ms | 42276 KiB | ||||
30 | Wrong answer | 93ms | 42128 KiB | ||||
31 | Wrong answer | 61ms | 25364 KiB | ||||
32 | Accepted | 43ms | 11928 KiB | ||||
33 | Accepted | 108ms | 34076 KiB | ||||
34 | Accepted | 92ms | 34204 KiB |