// Tom es Jerry.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
/*
#include <iostream>
#include <vector>
#include<deque>
#include <algorithm>
using namespace std;
struct adat
{
int lepTom, lepJerry, szelesseg, latTom, latJerry;
vector<pair<int, int>>sz;
};
int i, j, a, b,c, m, n, kezdTom, g,kezdJerry,Juk,akt;
int main()
{
cin >> n >> m >> kezdTom >> g >> Juk;
vector<adat>x(n + 1);
deque<int>probalkozasok(g + 1);
deque<int>v;
for (i = 1; i <= m; ++i)
{
cin >> a >> b>>c;
x[a].sz.push_back({ b,c });
x[b].sz.push_back({ a,c });
}
for (i = 1; i <= g; ++i)
{
cin >> a;
probalkozasok.push_back(a);
}
v.push_back(kezdTom);
x[kezdTom].lepTom = 0;
while (!v.empty())
{
akt = v.front();
v.pop_front();
for (auto& e : x[akt].sz)
{
if (!x[e.first].latTom&&e.second==2)
{
x[e.first].lepTom = x[akt].lepTom + 1;
x[e.first].latTom = 1;
v.push_back(e.first);
}
}
}
/*while (!probalkozasok.empty())
{
kezdJerry = probalkozasok.front();
probalkozasok.pop_front();
}
return 0;
}*/
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include<algorithm>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
vector<vector<int> > gj, gt;
vector<int> dt;
vector<bool> vis;
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) {
deque<pii> q;
q.push_back({ dt[start] - 1, start });
while (!q.empty()) {
pii v = q.front();
q.pop_front();
if (v.fi < 0) continue;
vis[v.se] = true;
for (int x : gj[v.se]) {
if (vis[x]) continue;
q.push_back({ min(dt[x] - 1, v.fi - 1), 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);
vis.assign(n + 1, false);
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 (vis[a]) {
cout << "IGEN\n";
}
else {
cout << "NEM\n";
}
}
}
/*
9 11 6 3 1
1 2 1
1 3 1
2 4 1
3 4 2
3 5 2
4 7 1
3 5 2
5 6 2
6 8 1
7 9 1
8 9 1
7
8
9
*/
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Forditási hiba
exit status 1
main.cpp: In function 'void tom(int)':
main.cpp:83:25: error: 'INT_MAX' was not declared in this scope
83 | if (dt[x] < INT_MAX / 2) continue;
| ^~~~~~~
main.cpp:66:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
65 | #include<algorithm>
+++ |+#include <climits>
66 | using namespace std;
main.cpp: In function 'int main()':
main.cpp:111:22: error: 'INT_MAX' was not declared in this scope
111 | dt.assign(n + 1, INT_MAX / 2);
| ^~~~~~~
main.cpp:111:22: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
Exited with error status 1