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

Re:BFS~152K 0MS 水过~~

Posted by willdon at 2020-11-02 15:51:06 on Problem 1163
In Reply To:BFS~152K 0MS 水过~~ Posted by:fww at 2015-03-07 13:35:14
> #include<stdio.h>
> #include<string.h>
> 
> int n;
> short trian[102][102];
> short max1[2][102]={0};
> 
> int bfs(){
> 	int maxnum=0;
> 	int x,y;
> 	for(int i=1;i<n;++i)
> 		for(int j=0;j<i;++j)
> 			for(int k=0;k<2;++k){
> 				x=i+1;
> 				y=j+k;
> 				if(max1[x%2][y]<max1[i%2][j]+trian[x][y])
> 					max1[x%2][y]=max1[i%2][j]+trian[x][y];
> 			}
> 	for(int i=0;i<n;++i)
> 		if(max1[n%2][i]>maxnum)
> 			maxnum=max1[n%2][i];
> 	return maxnum;
> }
> 		
> int main(){
> 	scanf("%d",&n);
> 	for(int i=1;i<=n;++i)
> 		for(int j=0;j<i;++j)
> 			scanf("%d",&trian[i][j]);
> 	max1[1][0]=trian[1][0];
> 	printf("%d\n",bfs());
> 	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