38862023-03-03 14:47:31Erik_GepardTom és Jerry 1 (80)cpp17Accepted 80/80193ms24564 KiB
#include<bits/stdc++.h>
using namespace std;

#define pb push_back

vector<int> tgraf[100009];
vector<int> jgraf[100009];
vector<int> ttav;
vector<int> jtav;
vector<int> tvolt;
vector<int> jvolt;

void solve(){
    int n, m, t, p, e;
    cin>>n>>m>>t>>p>>e;
    ttav.assign(n+1, INT_MAX);
    jtav.assign(n+1, INT_MAX);
    tvolt.assign(n+1, 0);
    jvolt.assign(n+1, 0);
    for(int i=0; i<m; i++){
        int a, b, c;
        cin>>a>>b>>c;
        if(c==2){
            tgraf[a].pb(b);
            tgraf[b].pb(a);
        }
        jgraf[a].pb(b);
        jgraf[b].pb(a);
    }
    ttav[t]=0;
    tvolt[t]=1;
    queue<int> q;
    q.push(t);
    while(!q.empty()){
        int elso=q.front();
        q.pop();
        for(int szom : tgraf[elso]){
            if(!tvolt[szom]){
                ttav[szom]=ttav[elso]+1;
                tvolt[szom]=1;
                q.push(szom);
            }
        }
    }
    jtav[e]=0;
    jvolt[e]=1;
    priority_queue<pair<int, int>> pq;
    pq.push({ttav[e], e});
    while(!pq.empty()){
        pair<int, int> elso=pq.top();
        pq.pop();
        if(elso.first>=0){
        jvolt[elso.second]=true;
        for(int szom : jgraf[elso.second]){
            if(!jvolt[szom]){
                pq.push({min(ttav[szom]-1, elso.first-1),szom});
            }
        }
        }
    }
    for(int i=0; i<p; i++){
        int a;
        cin>>a;
        if(jvolt[a]) cout<<"IGEN\n";
        else cout<<"NEM\n";
    }
    return;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/06ms11400 KiB
2Accepted0/08ms11760 KiB
3Accepted4/46ms11596 KiB
4Accepted4/46ms11516 KiB
5Accepted4/46ms11780 KiB
6Accepted4/46ms11876 KiB
7Accepted4/46ms12032 KiB
8Accepted4/47ms12592 KiB
9Accepted4/48ms12708 KiB
10Accepted4/47ms12712 KiB
11Accepted4/417ms13708 KiB
12Accepted4/412ms13588 KiB
13Accepted4/428ms14880 KiB
14Accepted4/459ms17208 KiB
15Accepted4/4193ms24564 KiB
16Accepted4/450ms19888 KiB
17Accepted4/467ms21196 KiB
18Accepted4/479ms19644 KiB
19Accepted4/457ms19388 KiB
20Accepted4/448ms19068 KiB
21Accepted4/439ms17664 KiB
22Accepted4/4136ms23952 KiB