记录编号 326767 评测结果 TTTTTTTTTT
题目名称 为爱追寻 最终得分 0
用户昵称 GravatarAntiLeaf 是否通过 未通过
代码语言 C++ 运行时间 10.024 s
提交时间 2016-10-21 14:49:18 内存使用 11.89 MiB
显示代码纯文本
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
template<typename T,typename hash_function>
struct hash_set{//not multi,and must have operator =
	static const int p=1012457;
	vector<T>a[p+10];
	hash_function hash;
	int siz;
	hash_set(){
		for(int i=0;i<p;i++)a[i].clear();
		siz=0;
	}
	void insert(const T &x){
		int k=hash(x);
		if(!a[k].empty()){
			int cnt=a[k].size();
			for(int i=0;i<cnt;i++)if(a[k][i]==x)return;
		}
		siz++;
		a[k].push_back(x);
	}
	int count(const T &x){
		int k=hash(x);
		if(a[k].empty())return 0;
		int cnt=a[k].size();
		for(int i=0;i<cnt;i++)if(a[k][i]==x)return 1;
		return 0;
	}
	int size(){return siz;}
};
struct myhash{
	bool operator()(const pair<int,int> &a){
		return abs((a.first&32767)*(a.second>>16)^(a.second&32767)*(a.first>>16));
	}
};
hash_set<pair<int,int>,myhash>a;
int n,x,y,tx,ty,dx,dy;
int main(){
#define MINE
#ifdef MINE
	freopen("loverfinding.in","r",stdin);
	freopen("loverfinding.out","w",stdout);
#endif
	scanf("%d%d%d%d%d",&n,&x,&y,&tx,&ty);
	a.insert(make_pair(x,y));
	while(n--){
		scanf("%d%d",&dx,&dy);
		x+=dx;y+=dy;
		a.insert(make_pair(x,y));
		if(x==tx&&y==ty)break;
	}
	if(a.count(make_pair(tx,ty)))printf("%d",a.size());
	else printf("SingleDogMZX");
#ifndef MINE
	printf("\n-------------------------DONE-------------------------\n");
	for(;;);
#endif
	return 0;
}