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

Re:给你们一个出测试数据的程序吧,运行一下就输入数据输出数据都出来了,如果全对,你的程序没过找我,数据太多,你们可以写个文件比对程序

Posted by ylissensen at 2017-12-07 17:13:53 on Problem 1036
In Reply To:给你们一个出测试数据的程序吧,运行一下就输入数据输出数据都出来了,如果全对,你的程序没过找我,数据太多,你们可以写个文件比对程序 Posted by:HH_YT at 2012-08-15 10:38:48
> #include<stdio.h>
> #include<string.h>
> #include<stdlib.h>
> struct G
> {
> 	int t;
> 	int p;
> 	int s;
> }gangster[101],gangster1[101];
> int f[101];
> int n,k,t;
> int n1;
> int dp[101];
> FILE *in,*out;
> int abs(int a,int b)
> {
> 	return a>b?a-b:b-a;
> }
> int max(int a,int b)
> {
> 	return a>b?a:b;
> }
> int init()
> {
> 	int i,j;
> 	//memset(f,0,sizeof(f));
> 	for(i=1;i<=n;i++)
> 	{
> 		gangster[i].t=rand()%t+1;
> 		fprintf(in,"%d ",gangster[i].t);
> 	//	if(gangster[i].t>t)
> 	//		f[i]=1;
> 	}
> 	fprintf(in,"\n");
> 	for(i=1;i<=n;i++)
> 	{
> 		gangster[i].p=rand()%300+1;
> 		fprintf(in,"%d ",gangster[i].p);
> 	}
> 	fprintf(in,"\n");
> 	for(i=1;i<=n;i++)
> 	{
> 		gangster[i].s=rand()%k+1;
> 		fprintf(in,"%d ",gangster[i].s);
> 	//	if(gangster[i].s>k)
> 	//		f[i]=1;
> 	}
> 	fprintf(in,"\n");
> 	int flag[101];
> 	memset(flag,0,sizeof(flag));
> 	n1=0;
> 	for(i=1;i<=n;i++)
> 	{
> 		if(flag[i]==1||f[i]==1)
> 			continue;
> 		memcpy(&gangster1[++n1],&gangster[i],sizeof(G));
> 		for(j=i+1;j<=n;j++)
> 		{
> 			if(gangster[i].t==gangster[j].t&&gangster[i].s==gangster[j].s)
> 			{
> 				gangster1[n1].p+=gangster[j].p;
> 				flag[j]=1;
> 			}
> 		}
> 	}
> 	gangster1[0].t=0;
> 	gangster1[0].p=0;
> 	gangster1[0].s=0;
> 	dp[0]=0;
> 	for(i=1;i<=n1;i++)
> 		dp[i]=-1;
> 	G temp;
> 	for(i=1;i<=n1;i++)
> 		for(j=i+1;j<=n1;j++)
> 		{
> 			if(gangster1[i].t>gangster1[j].t)
> 			{
> 				memcpy(&temp,&gangster1[i],sizeof(G));
> 				memcpy(&gangster1[i],&gangster1[j],sizeof(G));
> 				memcpy(&gangster1[j],&temp,sizeof(G));
> 			}
> 		}
> 		for(i=1;i<=n1;i++)
> 		{
> 			for(j=0;j<i;j++)
> 			{
> 				if(dp[j]==-1)
> 					continue;
> 				if(gangster1[i].t-gangster1[j].t>=abs(gangster1[i].s,gangster1[j].s))
> 				{
> 					dp[i]=max(dp[i],dp[j]+gangster1[i].p);
> 				}
> 			}
> 		}
> 	return 0;
> }
> int main()
> {
> 	int i;
> 	int cases=1000;
> 	in=fopen("in.txt","w");
> 	out=fopen("out.txt","w");
> 	while(cases--)
> 	{
> 		n=rand()%100+1;
> 		k=rand()%100+1;
> 		t=rand()%30000+1;
> 		fprintf(in,"%d %d %d\n",n,k,t);
> 		int best=0;
> 		init();
> 		for(i=0;i<=n1;i++)
> 			if(dp[i]>best)
> 				best=dp[i];
> 		fprintf(out,"%d\n",best);
> 	}
> 	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