Submission #1088858
Source Code Expand
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;
#define INF 1e9
vector<vector<int> > d; // 隣接行列 適宜0とかINFとか
int n; // 頂点数
void warshall_floyd() {
rep (k, n) {
rep (i, n) {
rep (j, n) {
d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
}
}
}
int main() {
int m;
scanf("%d %d", &n, &m);
d.assign(n, vi(n, INF));
rep (i, n) {
d[i][i] = 0;
}
rep (i, m) {
int a, b, t;
scanf("%d %d %d", &a, &b, &t);
a -= 1;
b -= 1;
d[a][b] = d[b][a] = t;
}
warshall_floyd();
vi max_dist(n, 0);
int ans = INF;
rep (i, n) {
rep (j, n) {
max_dist[i] = max(max_dist[i], d[i][j]);
}
ans = min(ans, max_dist[i]);
}
printf("%d\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - バスと避けられない運命 |
User |
tspcx |
Language |
C++11 (GCC 4.8.1) |
Score |
100 |
Code Size |
1640 Byte |
Status |
AC |
Exec Time |
68 ms |
Memory |
1404 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:55:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &n, &m);
^
./Main.cpp:62:34: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d", &a, &b, &t);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt |
Case Name |
Status |
Exec Time |
Memory |
sample_01.txt |
AC |
27 ms |
1024 KB |
sample_02.txt |
AC |
21 ms |
1020 KB |
sample_03.txt |
AC |
22 ms |
1012 KB |
test_01.txt |
AC |
22 ms |
1020 KB |
test_02.txt |
AC |
59 ms |
1276 KB |
test_03.txt |
AC |
68 ms |
1404 KB |
test_04.txt |
AC |
35 ms |
1148 KB |
test_05.txt |
AC |
36 ms |
1140 KB |
test_06.txt |
AC |
22 ms |
1020 KB |
test_07.txt |
AC |
56 ms |
1272 KB |
test_08.txt |
AC |
22 ms |
1016 KB |
test_09.txt |
AC |
33 ms |
1104 KB |
test_10.txt |
AC |
23 ms |
1020 KB |
test_11.txt |
AC |
24 ms |
1016 KB |
test_12.txt |
AC |
41 ms |
1144 KB |
test_13.txt |
AC |
23 ms |
1020 KB |
test_14.txt |
AC |
25 ms |
1012 KB |
test_15.txt |
AC |
55 ms |
1272 KB |
test_16.txt |
AC |
23 ms |
1016 KB |
test_17.txt |
AC |
34 ms |
1148 KB |
test_18.txt |
AC |
41 ms |
1148 KB |
test_19.txt |
AC |
23 ms |
1020 KB |
test_20.txt |
AC |
25 ms |
1012 KB |
test_21.txt |
AC |
22 ms |
1024 KB |
test_22.txt |
AC |
29 ms |
1148 KB |
test_23.txt |
AC |
21 ms |
1016 KB |
test_24.txt |
AC |
60 ms |
1400 KB |
test_25.txt |
AC |
60 ms |
1360 KB |
test_26.txt |
AC |
29 ms |
1064 KB |
test_27.txt |
AC |
32 ms |
1148 KB |
test_28.txt |
AC |
60 ms |
1404 KB |
test_29.txt |
AC |
60 ms |
1400 KB |
test_30.txt |
AC |
24 ms |
1016 KB |
test_31.txt |
AC |
22 ms |
1020 KB |
test_32.txt |
AC |
60 ms |
1400 KB |
test_33.txt |
AC |
60 ms |
1400 KB |
test_34.txt |
AC |
21 ms |
1016 KB |
test_35.txt |
AC |
29 ms |
1144 KB |
test_36.txt |
AC |
60 ms |
1360 KB |