| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 150115 | 唐钧 | 最短路径 | C++ | Accepted | 100 | 0 MS | 292 KB | 392 | 2024-06-01 15:38:38 |
#include<bits/stdc++.h> using namespace std; int m[105][105],n,ans=1E9; void shortestway(int c,int s){ if(c==n){ ans=min(ans,s); return ; } for(int i=1;i<=n;i++){ if(m[c][i]!=-1){ shortestway(i,s+m[c][i]); } } } int main(){ memset(m,-1,sizeof(m)); cin>>n; while(1){ int a,b,c; cin>>a>>b>>c; if(a==0 and b==0 and c==0)break; m[a][b]=c; } shortestway(1,0); cout<<ans; }