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

Help,WA都N次了,帮忙看哈,给点测试数据,谢谢了!!!!!!!!!

Posted by 20054738 at 2007-04-03 21:06:30 on Problem 1581
先按解决的问题多少排序,看最大的解决问题个数的队伍是多少
若是一 ,就不用再比较penalty points
否则再次选出几个队伍的penalty points,在排序,就可得winner了,排序中注意到下表保持原来的顺序,跟着变
代码如下:
#include<iostream.h>
#include<stdio.h>

//using namespace std;

//犯了个错误,定义计算器为cout,应为count的,因为输出流也为cout,就出现了
//F:\ACM\1581\1581.cpp(77) : error C2297: '<<' : illegal, right operand has type 'char [30]'


#define max 10000
int main()
{
	int n,i,j,k=0,t,temp,count=0;//s;
	char name[max][30];
	int solve[max]={0},score[max]={0},submit[max][5]={0},plu[max][2]={0},flag[max]={0},flag1[max]={0};
	int bscore[max]={0},bflag[max]={0};
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>name[i];
		for(j=0;j<4;j++)
		{
			cin>>submit[i][j]>>plu[i][j];
			if(plu[i][j]!=0)
			{
				solve[i]++;
				score[i]=score[i]+(submit[i][j]-1)*20+plu[i][j];//多写了个加左边score[i]+
				flag[i]=i;
			}
		}
	}
	//冒泡排序
	for(i=0;i<n;i++)
	{
		for(j=i;j<n-i-1;j++)
		{
			if(solve[i]>solve[i+1])
			{
				temp=solve[i];
				solve[i]=solve[i+1];
				solve[i+1]=temp;
				//下标跟随
				t=i;
				flag[i]=flag[i+1];
				flag[i+1]=i;
			}
		}
		/*
		for(j=i;j<n-i-1;j++)
		{
		if(score[i]>slove[i+1])
		{
		temp=score[i];
		score[i]=score[i+1];
		score[i+1]=temp;
		//下标跟随
		t=i;
		flag1[i]=flag1[i+1];
		flag1[i+1]=i;
		}
		}
		*/
	}
	for(i=n-2;i>=0;i--)
	{
		if(solve[n-1]==solve[i])
		{
			//非i=k;
			k=i;
			count++;
		}
		if(solve[n-1]>solve[i])
			break;
	}
	if(0==count)
	{
		//s=flag[n-1];
	//	cout<<name[s]<<" "<<solve[n-1]<<" "<<score[s]<<endl;
		//puts(name[s]);
		//		cout<<" "<<solve[n-1]<<" "<<score[s]<<endl;
		cout<<name[flag[n-1]]<<" "<<solve[n-1]<<" "<<score[flag[n-1]]<<endl;
	}
	else
	{
		j=k+count;
		for(i=0;i<count;i++)
		{
			bflag[i]=flag[j];
			bscore[i]=score[flag[j]];
			j--;
		}
		for(i=0;i<count;i++)
		{
			for(j=i;j<count-i-1;j++)
			{
				if(bscore[i]>bscore[i+1])
				{
					temp=bscore[i];
					bscore[i]=bscore[i+1];
					bscore[i+1]=temp;
					//下标跟随
					t=i;
					bflag[i]=bflag[i+1];
					bflag[i+1]=i;
				}
			}
		}
		cout<<name[bflag[0]]<<" "<<solve[n-1]<<" "<<score[bflag[0]]<<endl;//<<score[0]<<endl;
		//cout<<name[bflag[0]]<<" "<<solve[bflag[0]]<<" "<<bscore[bflag[0]]<<endl;//<<score[0]<<endl;
	//	s=bflag[0];
		//	puts(name[s]);
		//			cout<<" "<<solve[s]<<" "<<score[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