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 me! 还是在WA...

Posted by jiaohang at 2006-11-04 18:05:03 on Problem 3067
In Reply To:间歇性的TLE->WA->TLE->WA...终于有了M*N的算法,但怎么会WA呢? Posted by:jiaohang at 2006-11-04 17:34:50
#include<stdio.h>
#include<string.h>
int main()
{
	int TT;
	int n[1001],N,M,K;
	long long R;
	int c[1001][1001];
	scanf("%d",&TT);
	for(int TTT=1;TTT<=TT;++TTT)
	{
		R=0;
		scanf("%d%d%d",&N,&M,&K);
		
		memset(n,0,sizeof(n));
		memset(c,0,sizeof(c));

		for(int i=0;i<K;++i)
		{
			int x,y;
			scanf("%d%d",&x,&y);
			c[x][y]++;
		}
		
		for(int x=1;x<=N;++x)
		{
			long long f=0;
			for(int y=1;y<=M;++y)
			{
				R+=f*n[y];
				if(c[x][y])
				{
					f+=c[x][y];
					n[y]+=c[x][y];
				}
			}
		}
		
		printf("Test case %d: %lld\n",TTT,R);
	}

	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