Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
做wa了……wrong answer 求大神们看下错哪儿了#include<algorithm> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> #include<iostream> #include<map> #include<queue> #include<stack> #include<string> #include<set> #include<utility> #include<vector> using namespace std; int n; int a[111][111]; bool vis[111]; int ans; vector<int> v; int main(){ cin>>n; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) cin>>a[i][j]; vis[1]=1; v.push_back(1); for (int i=1;i<=n-1;i++) { int mn=10000000,tt; for (int j=0;j<v.size();j++) for (int k=1;k<=n;k++) if (a[v[j]][k]&&a[v[j]][k]<mn&&!vis[k]) mn=a[v[j]][k],tt=k; vis[tt]=1; if (tt) ans+=mn; v.push_back(tt); } cout<<ans; return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator