8783 | 2024-01-30 00:48:46 | renn | Kutyavetélkedő | cpp17 | Wrong answer 0/100 | 123ms | 42292 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);
cout.tie(0);
ios::sync_with_stdio(0);
int n, k, m, a, b;
cin >> n >> k;
vector<int> feladatok(n+2, -1), legjobb(n+2, -1);
vector<unordered_set<int>> szabalyok(k+1);
for(int i = 0; i < n; i++)
cin >> feladatok[i];
cin >> m;
while(m--) {
cin >> a >> b;
if(a == k || b == k) continue;
szabalyok[a].insert(b);
}
legjobb[0] = (feladatok[0]-1) == k ? -1 : 1;
legjobb[1] = (feladatok[1]-1) == k ? -1 : 1;
for(int i = 0, j = 0; i < n; i++) {
if(j == 2) break;
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 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2016 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Wrong answer | 3ms | 2228 KiB | ||||
4 | Accepted | 3ms | 2460 KiB | ||||
5 | Accepted | 3ms | 2692 KiB | ||||
6 | Accepted | 2ms | 2736 KiB | ||||
7 | Accepted | 17ms | 5736 KiB | ||||
8 | Wrong answer | 17ms | 5816 KiB | ||||
9 | Wrong answer | 17ms | 5988 KiB | ||||
subtask3 | 0/19 | ||||||
10 | Accepted | 2ms | 3056 KiB | ||||
11 | Wrong answer | 3ms | 3180 KiB | ||||
12 | Wrong answer | 3ms | 3392 KiB | ||||
13 | Wrong answer | 2ms | 3480 KiB | ||||
14 | Wrong answer | 3ms | 3620 KiB | ||||
15 | Accepted | 2ms | 3476 KiB | ||||
16 | Wrong answer | 2ms | 3476 KiB | ||||
subtask4 | 0/34 | ||||||
17 | Wrong answer | 3ms | 3816 KiB | ||||
18 | Wrong answer | 4ms | 3940 KiB | ||||
19 | Wrong answer | 4ms | 4204 KiB | ||||
20 | Wrong answer | 4ms | 4208 KiB | ||||
21 | Wrong answer | 6ms | 4448 KiB | ||||
22 | Wrong answer | 6ms | 4748 KiB | ||||
subtask5 | 0/32 | ||||||
23 | Wrong answer | 35ms | 12092 KiB | ||||
24 | Wrong answer | 50ms | 15552 KiB | ||||
25 | Wrong answer | 45ms | 18564 KiB | ||||
26 | Wrong answer | 50ms | 20880 KiB | ||||
27 | Wrong answer | 50ms | 23108 KiB | ||||
28 | Wrong answer | 71ms | 18304 KiB | ||||
29 | Wrong answer | 111ms | 42188 KiB | ||||
30 | Accepted | 123ms | 42292 KiB | ||||
31 | Wrong answer | 76ms | 25604 KiB | ||||
32 | Wrong answer | 43ms | 12680 KiB | ||||
33 | Wrong answer | 78ms | 34568 KiB | ||||
34 | Wrong answer | 101ms | 34464 KiB |