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

郁闷,A不了啊,一直WA,为什么啊

Posted by fisheatscats at 2008-10-06 15:26:52 on Problem 3690
/*
	*代表1
	0代表0
*/

#include <iostream>
#include <memory.h>

using namespace std;

typedef long long VeryLONG;

int map[1001][1001],T,N,M,P,Q,last;
VeryLONG mainmatrix[1001][1001];
VeryLONG submatrix[101][51];
VeryLONG EXP2[52],ans;
bool ok[101];

int main()
{
	EXP2[0]=1;
	for (int i=1;i<=51;i++) EXP2[i]=2*EXP2[i-1];
	int tt=0;
	
	while (scanf("%d%d%d%d%d",&N,&M,&T,&P,&Q) && N>0)
	{
		tt++;
		ans=0;
		
		memset(map,0,sizeof(map));
		memset(mainmatrix,0,sizeof(mainmatrix));
		memset(submatrix,0,sizeof(submatrix));
		
		char lines[1002];
		gets(lines);
		VeryLONG tmp;
		for (int i=1;i<=N;i++)
		{
			gets(lines);
			for (int j=1;j<=M;j++)
				if (lines[j-1]=='*') map[i][j]=1;
				else map[i][j]=0;
		}
		
		for (int i=1;i<=N;i++)
		{
			tmp=0;
			for (int j=1;j<=M;j++)
			{
				tmp=tmp*2+map[i][j];
				if (j>=Q)
				{
					tmp-=map[i][j-Q]*EXP2[Q];
					mainmatrix[i][j]=tmp;
				}
			}
		}
		
		for (int i=1;i<=T;i++)
		{
			gets(lines);
			for (int j=1;j<=P;j++)
			{
				gets(lines);
				tmp=0;
				for (int k=1;k<=Q;k++)
					if (lines[k-1]=='*') tmp=tmp*2+1;
					else tmp=tmp*2;
				submatrix[i][j]=tmp;
			}
		}
		
		for (int i=1;i<=N-P+1;i++)
			for (int j=Q;j<=M;j++)
			{
				memset(ok,true,sizeof(ok));
				last=1;
				for (int row=1;row<=P && last>0;row++)
				{
					last=0;
					for (int k=1;k<=T;k++)
						if (ok[k] && submatrix[k][row]==mainmatrix[i+row-1][j])
							last++;
						else ok[k]=false;
				}
				ans+=last;
			}
			
		printf("Case %d: %d\n",tt,ans);
	}
	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