| 15327 | 2025-02-18 12:24:44 | Leventusz09 | A lehető legkevesebb metróval utazás (40 pont) | cpp17 | Forditási hiba |
#include <iostream>
#include <vector>
using namespace std;
struct Stop {
vector<int> et; // élek ide / innen
vector<int> ms; // élek metrói
};
bool ty[10000];
Stop ss[10000];
//int fs[10000];
int ff(int i, int f, int m, int t, vector<int> &v) {
ty[i] = 1;
if (i == t) return 0;
int min = INT16_MAX;
int pb = -1;
for (int ni = 0; ni < ss[i].et.size(); ni++) {
int n = ss[i].et[ni];
if (ty[n]/*n == f*/) continue;
int c = ff(n, i, ss[i].ms[ni], t, v);
if (c != -1 && c < min) {
if (m == ss[i].ms[ni]) {
min = c;
}
else {
min = c + 1;
pb = ss[i].ms[ni];
}
}
}
if (pb != -1) v.push_back(pb);
return min;
}
int main() {
int N, M, Ind, Erk;
cin >> N >> M >> Ind >> Erk;
Ind--; Erk--;
for (int i = 0, n, t; i < N; i++) {
cin >> n;
for (int j = 0, ls = -1; j < n; j++) {
cin >> t;
t--;
if (ls != -1) {
ss[t ].et.push_back(ls);
ss[ls].et.push_back( t);
ss[t ].ms.push_back( i);
ss[ls].ms.push_back( i);
}
ls = t;
}
}
int o = INT_MAX;
vector<int> x;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) ty[i] = 0;
vector<int> tx = { i };
int c = ff(Ind, -1, i, Erk, tx);
if (c < o) x = tx, o = c;
}
cout << o << endl;
for (int& i : x) cout << i + 1 << " ";
return 0;
}open /var/local/lib/isolate/444/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:60:17: error: 'INT_MAX' was not declared in this scope
60 | int o = INT_MAX;
| ^~~~~~~
main.cpp:3:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
2 | #include <vector>
+++ |+#include <climits>
3 |