Submission #1772313
Source Code Expand
#include<iostream> #include<vector> #include<queue> #include<algorithm> using namespace std; #define INF 1<<27; typedef pair<int,int>P; int min_cost[100005]; vector<P>node[100005]; int main(){ int n,m,ans=INF; cin>>n>>m; for(int i=1;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> >pq; for(int i=1;i<=n;++i){ fill(min_cost, min_cost+100005,1<<27); min_cost[i]=0; pq.push(P(0,i)); while(!pq.empty()){ P now=pq.top(); pq.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; pq.push(P(cost+ncost,next)); } } } sort(min_cost+1,min_cost+n+1,greater<int>()); if(ans>min_cost[1]) ans=min_cost[1]; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - スワップ |
User | GENBU |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1008 Byte |
Status | RE |
Exec Time | 101 ms |
Memory | 2560 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 0 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | sample_01.txt, sample_02.txt, test_13_69.txt, test_16_44.txt, test_40_40.txt, test_49_31.txt, test_51_74.txt, test_83_60.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | RE | 100 ms | 2560 KB |
sample_02.txt | RE | 101 ms | 2560 KB |
test_13_69.txt | RE | 100 ms | 2560 KB |
test_16_44.txt | RE | 100 ms | 2560 KB |
test_40_40.txt | RE | 100 ms | 2560 KB |
test_49_31.txt | RE | 100 ms | 2560 KB |
test_51_74.txt | RE | 100 ms | 2560 KB |
test_83_60.txt | RE | 101 ms | 2560 KB |