比赛 NOIP模拟赛by mzx Day1 评测结果 TTTTTTTTTE
题目名称 为爱追寻 最终得分 0
用户昵称 Marvolo 运行时间 9.177 s
代码语言 C++ 内存使用 18.56 MiB
提交时间 2016-10-19 21:56:01
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<iostream>
#define CK 3000001
#define C 1523333222
using namespace std;

int n,x0,y0,xt,yt,x,y,i,ans,X,Y;
int lx[3000010],ly[3000010];

inline void Hash(int p,int q){
	int a=0,b=0;
	a=(p%CK+65535)%CK;	b=(q%CK+65535)%CK;
	while (lx[a]!=C&&lx[a]!=p)	a=(a+1)%CK;
	while (ly[b]!=C&&ly[b]!=q)	b=(b+1)%CK;
	while (lx[a]==p&&ly[b]!=q)	a=(a+1)%CK;
	while (ly[b]==q&&lx[a]!=p)	b=(b+1)%CK;
	if (lx[a]==p&&ly[b]==q)	return;
	else {lx[a]=p;	ly[b]=q;	ans++;}
}

int main(){
	freopen("loverfinding.in","r",stdin);
	freopen("loverfinding.out","w",stdout);
	scanf("%d%d%d%d%d",&n,&x0,&y0,&xt,&yt);
	if (x0==xt&&y0==yt)	{printf("1\n");	return 0;}
	for (i=1;i<=CK;i++)	lx[i]=ly[i]=C;
	X=x0;	Y=y0;	Hash(x0,y0);
	for (i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		X+=x;	Y+=y;
		if (X==xt&&Y==yt)	{printf("%d\n",ans+1);	return 0;}
		Hash(X,Y);
	}
	printf("SingleDogMZX\n");
	return 0;
}