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

寒, WA!LCS哪里出错了,迷茫ing...请大牛指教 (含代码)

Posted by VitaminC at 2006-11-28 14:27:14 on Problem 3018
/*
	Problem ID: 3018
	User ID: VitaminC
	Time: 2006-11-28
*/

#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;

bool satisfy(vector<int> p, vector<int> q)
{
	int	len=p.size();
	for(int i=0; i<len; i++)
		if(p[i]>=q[i])
			return false;
	return true;
}

int main()
{
	const int MAX_N = 501;
	int n, d, MAX;
	int cnt[MAX_N];
	bool flag;
	vector<int> gift, temp;
	vector<vector<int> > box;
	while(2 == scanf("%d %d", &n, &d))
	{
		int i, j, num;
		flag=false;
		gift.clear();
		for(i=0; i<d; i++)
		{
			scanf("%d", &num);
			gift.push_back(num);
		}
		sort(gift.begin(), gift.end());
		box.clear();
		for(i=0; i<n; i++)
		{
			temp.clear();
			for(j=0; j<d; j++)
			{
				scanf("%d", &num);
				temp.push_back(num);
			}
			sort(temp.begin(), temp.end());
			box.push_back(temp);
			if(satisfy(gift, temp))
				flag=true;
			cnt[i]=1;
		}
		if(flag==false)
			goto out;
		sort(box.begin(), box.end());
		for(i=0; i<n-1; i++)
		{

			if(satisfy(box[i], gift))
				continue;
			for(j=i+1; j<n; j++)
				if(satisfy(box[i], box[j]) && cnt[i]+1>cnt[j])
					cnt[j]=cnt[i]+1;
		}
		MAX=0;
		for(i=0; i<n; i++)
			if(cnt[i]>MAX)
				MAX=cnt[i];
		out:
		if(flag==true)
			printf("%d\n", MAX);
		else
			printf("Please look for another gift shop!\n");
	}
	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