| 22045 | 2026-01-14 15:00:19 | hunzombi | Tom és Jerry 1 (80) | cpp17 | Forditási hiba |
#include <bits/stdc++.h>
#define PB push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, m, t, p, e;
cin >> n >> m >> t >> p >> e;
vector<vector<pii>> adj(n + 1);
for (int i=1; i <= m; i++) {
int u, v, c;
cin >> u >> v >> c;
adj[u].PB({v, c});
adj[v].PB({u, c});
}
vi qu(p);
for (int &x : qu) cin >> x;
vi dt(n + 1, -1);
queue<int> q;
dt[t] = 0;
q.push(t);
while (!q.empty()) {
int x = q.front(); q.pop();
for (pii ne : adj[x]) {
if (ne.second == 2 && dt[ne.first] == -1) {
dt[ne.first] = dt[x] + 1;
q.push(ne.first);
}
}
}
vi lastSafeTime(n + 1, -1);
lastSafeTime[e] = min(INF, dt[e]);
priority_queue<pii> pq;
lastSafeTime[e] = (dt[e] == -1) ? INF : dt[e] - 1;
if (lastSafeTime[e] >= 0) {
pq.push({lastSafeTime[e], e});
}
while (!pq.empty()) {
int curr_time = pq.top().first, u = pq.top().second; pq.pop();
if (curr_time < max_safe_time[u]) continue;
for (pii ne : adj[u]) {
int next = ne.first;
int new_time = curr_time - 1;
if (dt[next] == -1) {
new_time = min(new_time, INF);
} else {
new_time = min(new_time, dt[next] - 1);
}
if (new_time > lastSafeTime[next]) {
lastSafeTime[next] = new_time;
pq.push({new_time, next});
}
}
}
for (int q : qu) cout << ((lastSafeTime[q] < 0) ? "NEM" : "IGEN") << '\n';
return 0;
}
open /var/local/lib/isolate/429/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:60:25: error: 'max_safe_time' was not declared in this scope
60 | if (curr_time < max_safe_time[u]) continue;
| ^~~~~~~~~~~~~