45982023-03-30 10:43:53AblablablaTom és Jerry 1 (80)cpp17Time limit exceeded 64/80600ms10596 KiB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
int INF = 1e9 + 7;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m, t, p, e;
    cin >> n >> m >> t >> p >> e;
    vector<vector<pii>> csucsok(n + 1, vector<pii>(0, {0, 0}));
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin >> a >> b >> c;
        csucsok[a].push_back(pii(b, c));
        csucsok[b].push_back(pii(a, c));
    }

    vector<int> tom(n + 1, INF);
    queue<int> bejar1;
    bejar1.push(t);
    int aktualis = 1;
    int kovi = 0;
    int melyseg = 0;
    vector<bool> bejart1(n + 1, false);
    while(!bejar1.empty()){
        int akt = bejar1.front();
        bejar1.pop();


        for(pii x : csucsok[akt]){
            if(x.second == 2 && tom[x.first] == INF && !bejart1[x.first]){
                bejar1.push(x.first);
                bejart1[x.first] = true;
                kovi++;
            }
        }

        tom[akt] = min(tom[akt], melyseg);
        aktualis--;
        if(aktualis == 0){
            swap(aktualis, kovi);
            melyseg++;
        }

    }


    for(int i = 0; i < p; i++){
        int a;
        cin >> a;
        queue<int> bejar;
        bejar.push(a);
        aktualis = 1;
        kovi = 0;
        melyseg = 0;
        vector<bool> bejart(n + 1, false);
        bejart[a] = true;
        while(!bejar.empty()){
            int akt = bejar.front();
            bejar.pop();

            if(akt == e){
                break;
            }

            for(pii x : csucsok[akt]){
                if(melyseg + 1 < tom[x.first] && !bejart[x.first]){
                    bejar.push(x.first);
                    bejart[x.first] = true;
                    kovi++;
                }
            }

            aktualis--;
            if(aktualis == 0){
                swap(aktualis, kovi);
                melyseg++;
            }

        }

        if(bejart[e]){
            cout << "IGEN\n";
        } else{
            cout << "NEM\n";
        }

        /*while(!bejar.empty()){
            bejar.pop();
        }*/
    }
}
SubtaskSumTestVerdictTimeMemory
base64/80
1Accepted0/03ms1828 KiB
2Accepted0/04ms2284 KiB
3Accepted4/43ms2268 KiB
4Accepted4/43ms2444 KiB
5Accepted4/43ms2664 KiB
6Accepted4/43ms2872 KiB
7Accepted4/43ms3248 KiB
8Accepted4/43ms3244 KiB
9Accepted4/44ms3260 KiB
10Accepted4/44ms3560 KiB
11Accepted4/47ms4132 KiB
12Accepted4/48ms4580 KiB
13Accepted4/413ms5104 KiB
14Accepted4/423ms6844 KiB
15Accepted4/432ms7832 KiB
16Accepted4/437ms10168 KiB
17Accepted4/457ms10596 KiB
18Accepted4/430ms8564 KiB
19Time limit exceeded0/4600ms5664 KiB
20Time limit exceeded0/4572ms5712 KiB
21Time limit exceeded0/4579ms5192 KiB
22Time limit exceeded0/4560ms6492 KiB