【HDU1224】Free DIY Tour(动态规划DP)

Categories: 数据结构和算法
Tags: ,
Comments: No Comments
Published on: 2011 年 05 月 11 日

Weiwei is a software engineer of ShiningSoft. He has just excellently fulfilled a software project with his fellow workers. His boss is so satisfied with their job that he decide to provide them a free tour around the world. It's a good chance to relax themselves. To most of them, it's the first time to go abroad so they decide to make a collective tour.

The tour company shows them a new kind of tour circuit - DIY circuit. Each circuit contains some cities which can be selected by tourists themselves. According to the company's statistic, each city has its own interesting point. For instance, Paris has its interesting point of 90, New York has its interesting point of 70, ect. Not any two cities in the world have straight flight so the tour company provide a map to tell its tourists whether they can got a straight flight between any two cities on the map. In order to fly back, the company has made it impossible to make a circle-flight on the half way, using the cities on the map. That is, they marked each city on the map with one number, a city with higher number has no straight flight to a city with lower number.
Note: Weiwei always starts from Hangzhou(in this problem, we assume Hangzhou is always the first city and also the last city, so we mark Hangzhou both 1 and N+1), and its interesting point is always 0.
Now as the leader of the team, Weiwei wants to make a tour as interesting as possible. If you were Weiwei, how did you DIY it?

using namespace std;
const int maxn=105;

int v[maxn];
int father[maxn];
int map[maxn][maxn];
int dp[maxn];

void show(int n){
int main()
	int t,c=0;cin>>t;

		int n;cin>>n;
		for(int i=1;i<=n;i++)cin>>v[i],father[i]=1;
		int m,a,b;cin>>m;
		for(int i=1;i<=m;i++)cin>>a>>b,map[a][b]=1;
		for(int i=1;i<=n+1;i++)
			for(int j=1;j<i;j++){
	    printf("CASE %d#\n",++c);
        printf("points : %d\n",dp[n+1]);
        printf("circuit : ");
		if(t!=0) printf("\n");


No Comments - Leave a comment

Leave a comment

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Welcome , today is 星期六, 2019 年 02 月 23 日