forked from maiquynhtruong/algorithms-and-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva1247-interstar-transport.cpp
56 lines (54 loc) · 1.12 KB
/
uva1247-interstar-transport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <bits/stdc++.h>
using namespace std;
int V = 27;
int parent[27][27];
void floyd_warshall() {
for (int k = 0; k < V; k++) {
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
if (adjMat[i][j] < adjMat[i][k] + adjMat[k][j]) {
adjMat[i][j] = adjMat[i][k] + adjMat[k][j];
parent[i][j] = parent[k][j];
}
}
}
}
}
void printPath(int i, int j) {
if (i != j) printPath(i, parent[i][j]);
cout << char(j + 'A') << " ";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> S >> P;
int adjMat[105][105];
for (int i = 0; i < V; i++) {
for (int j = 0; j < V; j++) {
adjMat[i][j] = INF;
parent[i][j] = i;
parent[j][i] = j;
}
}
for (int i = 0; i < P; i++) {
cin >> s >> e >> d;
int u = s - 'A', v = e - 'A';
adjMat[u][v] = d;
adjMat[v][u] = d;
}
cin >> N;
for (int i = 0; i < N; i++) {
cin >> s >> e;
int u = s - 'A', v = e - 'A';
if (schedule[u] == 1 && schedule[v] == 1) {
printPath(u, v);
} else if (schedule[u] == 1) {
for (int i = 0; i < V; i++) {
if (adjMat[u][i])
}
} else if (schedule[v] == 1) {
} else {
}
cout << "\n";
}
}