87832024-01-30 00:48:46rennKutyavetélkedőcpp17Wrong answer 0/100123ms42292 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]));
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1824 KiB
2Accepted3ms2016 KiB
subtask20/15
3Wrong answer3ms2228 KiB
4Accepted3ms2460 KiB
5Accepted3ms2692 KiB
6Accepted2ms2736 KiB
7Accepted17ms5736 KiB
8Wrong answer17ms5816 KiB
9Wrong answer17ms5988 KiB
subtask30/19
10Accepted2ms3056 KiB
11Wrong answer3ms3180 KiB
12Wrong answer3ms3392 KiB
13Wrong answer2ms3480 KiB
14Wrong answer3ms3620 KiB
15Accepted2ms3476 KiB
16Wrong answer2ms3476 KiB
subtask40/34
17Wrong answer3ms3816 KiB
18Wrong answer4ms3940 KiB
19Wrong answer4ms4204 KiB
20Wrong answer4ms4208 KiB
21Wrong answer6ms4448 KiB
22Wrong answer6ms4748 KiB
subtask50/32
23Wrong answer35ms12092 KiB
24Wrong answer50ms15552 KiB
25Wrong answer45ms18564 KiB
26Wrong answer50ms20880 KiB
27Wrong answer50ms23108 KiB
28Wrong answer71ms18304 KiB
29Wrong answer111ms42188 KiB
30Accepted123ms42292 KiB
31Wrong answer76ms25604 KiB
32Wrong answer43ms12680 KiB
33Wrong answer78ms34568 KiB
34Wrong answer101ms34464 KiB