Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

傻逼们过来拷

Posted by ouwenbo at 2015-08-21 10:36:53 on Problem 2394
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
using namespace std;    
int a[510][510],ss[510],S[110],f,p,c,m,x,y,z;      
bool v[510];    
void findmax()
{  
    memset(v,0,sizeof(v));  
    for(int i=1;i<=f;i++)ss[i]=9999999;  
    ss[1]=0;  
    for(int i=1;i<=f;i++) 
	{  
        int ans=0,max=9999999;  
        for(int j=1;j<=f;j++) 
		{  
            if(v[j]==false&& ss[j]<max)
			{  
                max=ss[j];  
                ans=j;  
            }  
        }  
        if(ans==0)return ;
        v[ans]=true;  
        for(int j=1;j<=f;j++) 
		{  
            if(a[ans][j]!=999999 &&ss[j]>ss[ans]+a[ans][j])  
                ss[j]=ss[ans]+a[ans][j];  
        }  
    }  
}  
void Solve()
{  
    for(int i=1;i<=f;i++)  
      for(int j=1;j<=f;j++) 
        a[i][j]=9999999;  
}  
int main() 
{  
    scanf("%d%d%d%d",&f,&p,&c,&m);  
    memset(a,0x3f,sizeof(a));  
    memset(S,0,sizeof(S));  
    for(int i=1;i<=p;i++)
	{  
        scanf("%d%d%d",&x,&y,&z);  
        a[x][y]=a[y][x]=min(a[x][y],z);  
    }  
    findmax();  
    int l,num=0;  
    for(int i=1;i<=c;i++)
	{  
        scanf("%d",&l);  
        if(ss[l]<=m)  S[num++]=i;  
    }  
    printf("%d\n",num);  
    for(int i=0;i<num;i++)  printf("%d\n",S[i]);  
    return 0;  
} 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator