8661 | 2024-01-25 01:11:10 | renn | Kutyavetélkedő | cpp17 | Wrong answer 34/100 | 112ms | 42404 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 = 0; 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 | Accepted | 3ms | 2012 KiB | ||||
2 | Wrong answer | 3ms | 2028 KiB | ||||
subtask2 | 0/15 | ||||||
3 | Accepted | 3ms | 2240 KiB | ||||
4 | Accepted | 2ms | 2284 KiB | ||||
5 | Accepted | 2ms | 2288 KiB | ||||
6 | Accepted | 3ms | 2428 KiB | ||||
7 | Wrong answer | 19ms | 7228 KiB | ||||
8 | Accepted | 25ms | 7328 KiB | ||||
9 | Accepted | 25ms | 7488 KiB | ||||
subtask3 | 0/19 | ||||||
10 | Accepted | 2ms | 2940 KiB | ||||
11 | Wrong answer | 2ms | 2940 KiB | ||||
12 | Accepted | 3ms | 3064 KiB | ||||
13 | Accepted | 2ms | 3072 KiB | ||||
14 | Accepted | 3ms | 3064 KiB | ||||
15 | Accepted | 3ms | 3212 KiB | ||||
16 | Accepted | 2ms | 3064 KiB | ||||
subtask4 | 34/34 | ||||||
17 | Accepted | 3ms | 3156 KiB | ||||
18 | Accepted | 4ms | 3648 KiB | ||||
19 | Accepted | 6ms | 4120 KiB | ||||
20 | Accepted | 6ms | 4080 KiB | ||||
21 | Accepted | 6ms | 4304 KiB | ||||
22 | Accepted | 7ms | 4656 KiB | ||||
subtask5 | 0/32 | ||||||
23 | Wrong answer | 34ms | 12192 KiB | ||||
24 | Accepted | 50ms | 15532 KiB | ||||
25 | Accepted | 56ms | 18360 KiB | ||||
26 | Wrong answer | 43ms | 21028 KiB | ||||
27 | Accepted | 57ms | 22948 KiB | ||||
28 | Wrong answer | 70ms | 18332 KiB | ||||
29 | Wrong answer | 98ms | 42404 KiB | ||||
30 | Wrong answer | 94ms | 42284 KiB | ||||
31 | Wrong answer | 56ms | 25360 KiB | ||||
32 | Accepted | 45ms | 11728 KiB | ||||
33 | Accepted | 112ms | 33864 KiB | ||||
34 | Accepted | 97ms | 33884 KiB |