比赛 NOIP模拟赛by mzx Day1 评测结果 TTTTTTTTTT
题目名称 为爱追寻 最终得分 0
用户昵称 可以的. 运行时间 10.007 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2016-10-19 21:28:26
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <deque>
#include <map>
#define Mem(a,v) memset(a,v,sizeof(a));
using namespace std;
/*
freopen(".in","r",stdin);
	freopen(".out","w",stdout);
getchar(); getchar();
	return 0;
*/

int N,cnt;
struct node
{
	int x,y;
	node(){;}
	node(int a,int b){x = a; y = b;}
	bool operator < (const node &b)const
	{
		if(x < b.x)return 1;
		if(x > b.x)return 0;
		if(y < b.y)return 1;
		return 0; 	
	}
	bool operator == (const node &b)const
	{
		return (x==b.x && y==b.y);	
	}
}S,T,cur;
map<node,bool> mp;

void read(int &res){
	int x,f=1; char ch;
	while(ch=getchar(),ch<'0'||ch>'9')if(ch=='-')f=-1;
	x = ch - 48;
	while(ch=getchar(),ch>='0'&&ch<='9')x=x*10+ch-48;
	res = x * f;	
}

int main(){
	freopen("loverfinding.in","r",stdin);
	freopen("loverfinding.out","w",stdout);
	
	read(N);
	read(S.x); read(S.y);
	read(T.x); read(T.y);
	if(S == T){
		puts("1"); 	//getchar(); getchar();
		return 0;
	}
	cur = S;
	mp[S] = 1; cnt++;
	for(int i=1;i<=N;i++){
		int cx,cy; read(cx); read(cy);
		cur.x = cur.x + cx;
		cur.y = cur.y + cy;
		bool ufs;
		ufs = mp.count(cur);
		if(!ufs) cnt++;
		mp[cur] = 1;
		if(cur == T){
			printf("%d\n",cnt);
			//getchar(); getchar();
			return 0;	
		}
	} 
	if(!mp[T]){ puts("SingleDogMZX"); return 0; }
	//getchar(); getchar();
	return 0;
}