-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path1502MPIMaelstrom.cpp
More file actions
42 lines (41 loc) · 992 Bytes
/
1502MPIMaelstrom.cpp
File metadata and controls
42 lines (41 loc) · 992 Bytes
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
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <utility>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string.h>
#include <ctype.h>
#include <climits>
using namespace std;
const int INF = INT_MAX / 2;
const int N = 100;
int g[N][N];
int n, w;
char buf[20];
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) g[i][j] = INF;
for (int i = 1; i < n; i++)
for (int j = 0; j < i; j++) {
scanf("%s", buf);
if(buf[0]=='x') continue;
g[i][j] = g[j][i] = atoi(buf);
}
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
int best = 0;
for (int i = 1; i < n; i++) best = max(best, g[0][i]);
printf("%d\n", best);
return 0;
}