#include<iostream> #include<algorithm> #include<vector> #include<limits> using namespace std; int main(){ int n, m, k; while (cin >> n >> m >> k) { vector<int> a(m), b(m), c(m); for (int i = 0; i < m; i++) cin >> a[i] >> b[i] >> c[i]; while (k--) { int x, y; cin >> x >> y; vector<int> md(m + 1, INT_MAX), flag(m + 1,1); md[x] = 0; vector<int> list; list.push_back(x); do { for (int i = 0; i < m; i++) if (a[i] == list[list.size() - 1]) { md[b[i]] =min(md[a[i]] + c[i], md[b[i]]); if (b[i] != y && flag[b[i]]) { list.push_back(b[i]); flag[b[i]]--; } } list.pop_back(); } while (!list.empty()); cout << md[y] << endl; } } } /* Main.cc: In function 'int main()': Main.cc:16:26: error: 'INT_MAX' was not declared in this scope vector<int> md(m + 1, INT_MAX), flag(m + 1,1); ^~~~~~~ Main.cc:16:26: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'? Main.cc:4:1: +#include <climits> #include<limits> Main.cc:16:26: vector<int> md(m + 1, INT_MAX), flag(m + 1,1); ^~~~~~~ */ |
Double click to view unformatted code.