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 yujiashan at 2006-12-03 15:48:34 on Problem 2379
#include<stdio.h>
#include<stdlib.h>
struct mmd
{
	int ci,pi,ti,ri;
}run[1000];
struct nnd
{
	int solve,time,name;
}team[500];
int cmp1(const void *a,const void *b)
{
	mmd *aa=(mmd*)a;
	mmd *bb=(mmd*)b;
	if(aa->ci!=aa->ci)
		return aa->ci-bb->ci;
	if(aa->pi!=bb->pi)
		return aa->pi-bb->pi;
	if(aa->ti!=bb->ti)
		return aa->ti-bb->ti;
	return bb->ri-aa->ri;
}
int cmp2(const void *a,const void *b)
{
	nnd *aa=(nnd*)a;
	nnd *bb=(nnd*)b;
	if(aa->solve!=bb->solve)
		return bb->solve-aa->solve;
	if(aa->time!=bb->time)
		return aa->time-bb->time;
	return aa->name-bb->name;
}
int main()
{
	int c,n,i,j,k;
	scanf("%d%d",&c,&n);
	for(i=0;i<n;i++)
         scanf("%d%d%d%d",&run[i].ci,&run[i].pi,&run[i].ti,&run[i].ri);
	qsort(run,n,sizeof(run[0]),cmp1);
	for(i=1;i<=c;i++)
	{
                  team[i].solve=0;
		team[i].time=0;
		team[i].name=i;
	}
	for(i=0;i<n;i++)
	{
		for(j=i+1;j<n;j++)
			if(!(run[i].ci==run[j].ci&&run[i].pi==run[j].pi))
				break;
		for(k=i;k<j;k++)
			if(run[k].ri==1)
				break;
		if(run[k].ri==1)
                  {
			team[run[i].ci].solve++;
			team[run[i].ci].time+=run[k].ti+1200*(k-i);
		}
		i=j-1;
	}
	qsort(&team[1],c,sizeof(team[1]),cmp2);
	printf("%d",team[1].name);
	for(i=2;i<=c;i++)
		printf(" %d",team[i].name);
	printf("\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