Submission #1772398
Source Code Expand
#include<iostream> #include<vector> #include<queue> using namespace std; typedef pair<int,int>P; int main(){ int n,m; cin>>n>>m; vector<P>node[100005]; int min_cost[100005]; int INF=1<<27; for(int i=0;i<m;i++){ int a,b,cost; cin>>a>>b>>cost; node[a].push_back(P(b,cost)); node[b].push_back(P(a,cost)); } priority_queue<P,vector<P>,greater<P> >pg; int ans,bns=INF,answer,z; for(int cnt=0;cnt<n;cnt++){ for(int i=0;i<n+1;i++){ min_cost[i]=INF; } pg.push(P(0,cnt+1)); while(!pg.empty()){ P now=pg.top(); pg.pop(); int cost=now.first; int pos=now.second; for(int i=0;i<node[pos].size();i++){ int next=node[pos][i].first; int ncost=node[pos][i].second; if(cost+ncost<min_cost[next]){ min_cost[next]=cost+ncost; pg.push(P(cost+ncost,next)); } } } ans=0; int max=0; for(int i=0;i<n;i++){ if(cnt==i){ continue; } ans+=min_cost[i+1]; if(max<min_cost[i+1]){ max=min_cost[i+1]; } } if(ans<bns){ answer=max; bns=ans; z=cnt+1; } } cout<<answer<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - バスと避けられない運命 |
User | ei1704 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1189 Byte |
Status | WA |
Exec Time | 257 ms |
Memory | 3968 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 | 3 ms | 2560 KB |
sample_02.txt | AC | 3 ms | 2560 KB |
sample_03.txt | AC | 2 ms | 2816 KB |
test_01.txt | AC | 2 ms | 2688 KB |
test_02.txt | WA | 8 ms | 2560 KB |
test_03.txt | WA | 257 ms | 3968 KB |
test_04.txt | WA | 17 ms | 2688 KB |
test_05.txt | WA | 81 ms | 3072 KB |
test_06.txt | AC | 11 ms | 2688 KB |
test_07.txt | WA | 190 ms | 3840 KB |
test_08.txt | WA | 3 ms | 2560 KB |
test_09.txt | WA | 56 ms | 3328 KB |
test_10.txt | WA | 9 ms | 2688 KB |
test_11.txt | WA | 10 ms | 2688 KB |
test_12.txt | WA | 35 ms | 2688 KB |
test_13.txt | WA | 11 ms | 2688 KB |
test_14.txt | AC | 15 ms | 2688 KB |
test_15.txt | WA | 174 ms | 3712 KB |
test_16.txt | WA | 17 ms | 2816 KB |
test_17.txt | WA | 63 ms | 3072 KB |
test_18.txt | WA | 35 ms | 2688 KB |
test_19.txt | WA | 19 ms | 2688 KB |
test_20.txt | WA | 15 ms | 2688 KB |
test_21.txt | WA | 3 ms | 2560 KB |
test_22.txt | WA | 21 ms | 2688 KB |
test_23.txt | WA | 3 ms | 2560 KB |
test_24.txt | WA | 5 ms | 2560 KB |
test_25.txt | WA | 6 ms | 2560 KB |
test_26.txt | WA | 4 ms | 2560 KB |
test_27.txt | WA | 4 ms | 2560 KB |
test_28.txt | WA | 5 ms | 2560 KB |
test_29.txt | WA | 6 ms | 2560 KB |
test_30.txt | WA | 3 ms | 2560 KB |
test_31.txt | WA | 3 ms | 2560 KB |
test_32.txt | WA | 5 ms | 2560 KB |
test_33.txt | WA | 5 ms | 2944 KB |
test_34.txt | WA | 3 ms | 2944 KB |
test_35.txt | WA | 4 ms | 2560 KB |
test_36.txt | AC | 5 ms | 2560 KB |