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

找了1个小时也没找到错的地方 请好心人帮忙看看啊 谢谢

Posted by 200694068 at 2008-02-27 19:43:15 on Problem 1029
#include<iostream.h>
#include<stdio.h>
#include<math.h>
int w[1001];
int a[101][10001];
char c[102];
int b[101];
bool check1[1001];
int main()
{
	int N,K,i,j,n;

	scanf("%d%d",&N,&K);
	for (i=1;i<=N;i++)
	{
		w[i]=1;
	}
	for (i=0;i<K;i++)
	{
		cin>>b[i];
		for (j=0;j<2*b[i];j++)
		{
			cin>>a[i][j];
			check1[a[i][j]]=1;

		}
		cin>>c[i];
	}
	int wl,wr,k;
	bool check;
	int sum=0;
	for (j=1;j<=N;j++)
		if(check1[j]==1)sum++;
	
		if(sum<=N-2){cout<<0<<endl;return 0;}//如果有2个硬币没有出现在数据中则输出0
	for (i=1;i<=N;i++)
	{
		w[i]=2;	
		for (j=0;j<K;j++)//枚举每一个硬币
		{
			check=0;
			wl=wr=0;
			for (k=0;k<b[j];k++)
				wl+=w[a[j][k]];
			for (k=b[j];k<2*b[j];k++)
				wr+=w[a[j][k]];
			if(c[j]=='>')		
				if(wl>wr)
					check=1;;
			if(c[j]=='<')
				if(wl<wr)check=1;
			if(c[j]=='=')
				if(wl==wr)check=1;

			if(check==0)
				break;	
		}
		if(j==K)
		{
			cout<<i<<endl; 
			return 0;
		}
		w[i]=0;
		for (j=0;j<K;j++)
		{
			check=0;
			wl=wr=0;
			for (k=0;k<b[j];k++)
				wl+=w[a[j][k]];
			for (k=b[j];k<2*b[j];k++)
				wr+=w[a[j][k]];
			
			if(c[j]=='>')
				if(wl>wr)
					check=1;;
			if(c[j]=='<')
				if(wl<wr)check=1;
			if(c[j]=='=')
				if(wl==wr)check=1;

			if(check==0)
				break;
			else
				check=0;
			
		}
		if(j==K)
		{
			cout<<i<<endl;
			return 0;
		}
		w[i]=1;
	}
	if(i==N+1)cout<<0<<endl;
	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