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了?我测试给的数据没问题呀!!高手帮忙看看:

Posted by zhb_msqx at 2007-08-21 20:56:55 on Problem 1274
#include <iostream>
#include <fstream>
using namespace std;

int n,m;
int cow[200][200];//表示第i只猪所喜欢的stall
int scow[200];  // 第i只猪喜欢的stall的数目

int mark[1000];//标识这个stall是否可用



int compute(int p){
	if(p==n)return 0;
	int max=0;
	for(int i=0;i<scow[p];i++){
		int tmp=0;
		if(mark[cow[p][i]]==0){
			mark[cow[p][i]]=1;
			tmp=1+compute(p+1);
			if(tmp>max)max=tmp;
			mark[cow[p][i]]=0;
		}
	}
	int tmp=0;
	tmp=compute(p+1);
	if(tmp>max)max=tmp;
	return max;
}


void init(){
	memset(cow,0,sizeof(cow));
	memset(scow,0,sizeof(scow));
	memset(mark,0,sizeof(mark));
}

void main(){
//	ifstream cin("data.txt");
	cin>>n>>m;
	init();
	for(int i=0;i<n;i++){
		cin>>scow[i];
		for(int j=0;j<scow[i];j++){
			cin>>cow[i][j];
		}
	}
	int max=compute(0);
	cout<<max<<endl;

}

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