Submission #1604015
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define INF 1e9 typedef pair<int,int> P; struct Graph{ Graph(int n):E(n),d(n){}; vector<vector<P>>E; vector<int>d; void add_edge(int a,int b,int c){ E[a].push_back({b,c}); } bool bellmanFord(int s){ int sz=d.size(); fill(d.begin(),d.end(),INF); d[s]=0; for(int i=0;i<sz;++i) for(int j=0;j<sz;++j) for(P& p:E[j]){ if(d[j]!=INF&&d[j]+p.second<d[p.first]) d[p.first]=d[j]+p.second; if(i==sz-1)return true; } return false; } }; main(){ int n,m,a,b,c,x=INF; cin>>n>>m; Graph E(n); for(int i=0;i<m;++i){ cin>>a>>b>>c; E.add_edge(--a,--b,c),E.add_edge(b,a,c); } for(int i=0;i<n;++i){ E.bellmanFord(i); x=min(x,*max_element(E.d.begin(),E.d.end())); } cout<<x<<endl; }
Submission Info
Submission Time | |
---|---|
Task | D - バスと避けられない運命 |
User | moeruAI |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 872 Byte |
Status | TLE |
Exec Time | 5255 ms |
Memory | 1536 KB |
Judge Result
Set Name | All | ||||
---|---|---|---|---|---|
Score / Max Score | 0 / 100 | ||||
Status |
|
Set Name | Test Cases |
---|---|
All | sample_01.txt, sample_02.txt, sample_03.txt, 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 | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 1 ms | 256 KB |
test_01.txt | AC | 1 ms | 256 KB |
test_02.txt | AC | 160 ms | 256 KB |
test_03.txt | TLE | 5255 ms | 1536 KB |
test_04.txt | AC | 376 ms | 256 KB |
test_05.txt | AC | 3006 ms | 640 KB |
test_06.txt | AC | 113 ms | 384 KB |
test_07.txt | TLE | 5255 ms | 1408 KB |
test_08.txt | AC | 3 ms | 256 KB |
test_09.txt | AC | 1793 ms | 640 KB |
test_10.txt | AC | 86 ms | 384 KB |
test_11.txt | AC | 108 ms | 384 KB |
test_12.txt | AC | 1194 ms | 384 KB |
test_13.txt | AC | 119 ms | 384 KB |
test_14.txt | AC | 221 ms | 384 KB |
test_15.txt | TLE | 5255 ms | 1408 KB |
test_16.txt | AC | 266 ms | 384 KB |
test_17.txt | AC | 2148 ms | 640 KB |
test_18.txt | AC | 1137 ms | 384 KB |
test_19.txt | AC | 308 ms | 384 KB |
test_20.txt | AC | 224 ms | 384 KB |
test_21.txt | AC | 1 ms | 256 KB |
test_22.txt | AC | 470 ms | 384 KB |
test_23.txt | AC | 2 ms | 256 KB |
test_24.txt | AC | 162 ms | 256 KB |
test_25.txt | AC | 144 ms | 256 KB |
test_26.txt | AC | 38 ms | 256 KB |
test_27.txt | AC | 43 ms | 256 KB |
test_28.txt | AC | 159 ms | 256 KB |
test_29.txt | AC | 145 ms | 256 KB |
test_30.txt | AC | 8 ms | 256 KB |
test_31.txt | AC | 2 ms | 256 KB |
test_32.txt | AC | 161 ms | 256 KB |
test_33.txt | AC | 145 ms | 256 KB |
test_34.txt | AC | 3 ms | 256 KB |
test_35.txt | AC | 25 ms | 256 KB |
test_36.txt | AC | 159 ms | 256 KB |