Submission #628742
Source Code Expand
#include <cstdio> #include <algorithm> using namespace std; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) const int INF = 10000000; const int MAX_V = 300; int graph[MAX_V][MAX_V]; int N, M; bool visited[MAX_V]; int cost[MAX_V]; void init_graph() { REP(i, N) { REP(j, N) { if (i == j) graph[i][j] = 0; else graph[i][j] = INF; } } } void make() { REP(i, M) { int u, v, c; scanf("%d %d %d", &u, &v, &c); u--; v--; graph[u][v] = c; graph[v][u] = c; } } void init_dijkstra() { REP(i, N) visited[i] = false; REP(i, N) cost[i] = INF; } void dijkstra(int start) { init_dijkstra(); cost[start] = 0; while (true) { int mi = INF; int nxt = -1; visited[start] = true; REP(i, N) { if (visited[i]) continue; if (i != start) { int d = cost[start] + graph[start][i]; if (d < cost[i]) { cost[i] = d; } } if (mi > cost[i]) { mi = cost[i]; nxt = i; } } start = nxt; if (nxt == -1) break; } } void solve() { scanf("%d %d", &N, &M); init_graph(); make(); int mi = INF; REP(i, N) { dijkstra(i); int ma = 0; REP(j, N) { if (ma < cost[j]) ma = cost[j]; } mi = min(mi, ma); } printf("%d", mi); } int main() { solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - バスと避けられない運命 |
User | yurahuna |
Language | C++ (G++ 4.6.4) |
Score | 100 |
Code Size | 1651 Byte |
Status | AC |
Exec Time | 156 ms |
Memory | 1432 KB |
Compile Error
./Main.cpp: In function ‘void solve()’: ./Main.cpp:66:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] ./Main.cpp: In function ‘void make()’: ./Main.cpp:27:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
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 | 1052 KB |
sample_02.txt | AC | 27 ms | 1048 KB |
sample_03.txt | AC | 25 ms | 904 KB |
test_01.txt | AC | 25 ms | 920 KB |
test_02.txt | AC | 138 ms | 1400 KB |
test_03.txt | AC | 156 ms | 1304 KB |
test_04.txt | AC | 67 ms | 1176 KB |
test_05.txt | AC | 71 ms | 1180 KB |
test_06.txt | AC | 30 ms | 1180 KB |
test_07.txt | AC | 124 ms | 1176 KB |
test_08.txt | AC | 27 ms | 924 KB |
test_09.txt | AC | 56 ms | 1052 KB |
test_10.txt | AC | 30 ms | 1048 KB |
test_11.txt | AC | 32 ms | 984 KB |
test_12.txt | AC | 89 ms | 1176 KB |
test_13.txt | AC | 32 ms | 1048 KB |
test_14.txt | AC | 43 ms | 988 KB |
test_15.txt | AC | 118 ms | 1176 KB |
test_16.txt | AC | 35 ms | 1052 KB |
test_17.txt | AC | 58 ms | 1052 KB |
test_18.txt | AC | 81 ms | 1304 KB |
test_19.txt | AC | 36 ms | 1048 KB |
test_20.txt | AC | 34 ms | 1056 KB |
test_21.txt | AC | 24 ms | 928 KB |
test_22.txt | AC | 47 ms | 1176 KB |
test_23.txt | AC | 26 ms | 932 KB |
test_24.txt | AC | 134 ms | 1308 KB |
test_25.txt | AC | 144 ms | 1432 KB |
test_26.txt | AC | 51 ms | 1176 KB |
test_27.txt | AC | 60 ms | 1180 KB |
test_28.txt | AC | 133 ms | 1312 KB |
test_29.txt | AC | 134 ms | 1432 KB |
test_30.txt | AC | 29 ms | 1048 KB |
test_31.txt | AC | 27 ms | 928 KB |
test_32.txt | AC | 133 ms | 1304 KB |
test_33.txt | AC | 136 ms | 1304 KB |
test_34.txt | AC | 26 ms | 916 KB |
test_35.txt | AC | 46 ms | 1176 KB |
test_36.txt | AC | 133 ms | 1304 KB |