Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
150046 吴松韬 最短路径 C++ 通过 100 0 MS 292 KB 421 2024-06-01 14:48:52

Tests(10/10):


#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; }


测评信息: