| ||||||||||
| 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 | |||||||||
Re:赤裸裸的普里姆怎会超时??In Reply To:Re:赤裸裸的普里姆怎会超时?? Posted by:yangxw at 2010-11-17 23:29:22 > // yan.cpp : 定义控制台应用程序的入口点。
> //
> #include<iostream>
> using namespace std;
> int prim()
> {
> start:int n;
> cin>>n;
> if(n<3&&n>100)return 0;
> int a[101][101];
> int i,j,temp=0,min=0;
> for(i=1;i<n+1;i++)
> {
> for(j=1;j<n+1;j++)
> {
> cin>>a[i][j];
> }
> }
> for(i=1;i<n;i++)
> {
> temp=a[i][i+1];
> for(j=i+1;j<n;j++)
> {
> while(temp>a[i][j+1])temp=a[i][j+1];
> }
> min=min+temp;
> }
> cout<<min;
> goto start;
> return 0;
> }
> int main()
> {
> prim();
> return 0;
> }
>
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator