37082023-03-02 12:51:15ZsofiaKeresztelyTom és Jerry 1 (80)cpp14Wrong answer 48/80111ms14776 KiB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int> > gj, gt;
vector<int> dt, dj;

void tom(int start){
    queue<int> q;
    q.push(start);
    dt[start] = 0;
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int x : gt[v]){
            if (dt[x] < INT_MAX/2) continue;
            dt[x] = dt[v] + 1;
            q.push(x);
        }
    }
}

void jerry(int start){
    queue<int> q;
    q.push(start);
    dj[start] = dt[start] - 1;
    while (!q.empty()){
        int v = q.front();
        q.pop();
        for (int x : gj[v]){
            if (dj[x] >= 0) continue;
            dj[x] = min(dt[x] - 1, dj[v] - 1);
            if (dj[x] > 0) q.push(x);
        }
    }
}

int main()
{
    int n, m, t, p, j;
    cin >> n >> m >> t >> p >> j;
    gj.resize(n+1);
    gt.resize(n+1);
    dt.assign(n+1, INT_MAX/2);
    dj.assign(n+1, -1);
    while (m--){
        int a, b, w;
        cin >> a >> b >> w;
        gj[a].push_back(b);
        gj[b].push_back(a);
        if (w == 2){
            gt[a].push_back(b);
            gt[b].push_back(a);
        }
    }
    tom(t);
    jerry(j);
    while (p--){
        int a;
        cin >> a;
        if (dj[a] < 0){
            cout << "NEM\n";
        }
        else{
            cout << "IGEN\n";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base48/80
1Accepted0/03ms1812 KiB
2Wrong answer0/04ms2316 KiB
3Accepted4/43ms2264 KiB
4Accepted4/43ms2480 KiB
5Wrong answer0/43ms2668 KiB
6Accepted4/43ms2888 KiB
7Accepted4/43ms3288 KiB
8Wrong answer0/44ms3540 KiB
9Wrong answer0/44ms3728 KiB
10Accepted4/44ms3852 KiB
11Accepted4/410ms4508 KiB
12Accepted4/414ms5668 KiB
13Accepted4/423ms6436 KiB
14Accepted4/445ms8840 KiB
15Wrong answer0/463ms9492 KiB
16Accepted4/467ms14776 KiB
17Accepted4/4100ms14196 KiB
18Wrong answer0/463ms11296 KiB
19Wrong answer0/487ms13444 KiB
20Wrong answer0/471ms13072 KiB
21Accepted4/468ms10792 KiB
22Wrong answer0/4111ms13612 KiB