比赛 NOIP模拟赛by mzx Day1 评测结果 TTTTTTTTTT
题目名称 为爱追寻 最终得分 0
用户昵称 Theodore 运行时间 10.007 s
代码语言 C++ 内存使用 36.84 MiB
提交时间 2016-10-19 20:50:26
显示代码纯文本
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

ll n,xst,yst,xt,yt,ans=1,maxn=0;
ll xx[1000010],yy[1000010];
bool flag[2510][2510]={};
struct T{
	ll x,y;
}e[1000010];

ll read(){
	char ch=getchar();ll x=0,f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
void init(){
	n=read(),xst=read(),yst=read(),xt=read(),yt=read();
	for(int i=1;i<=n;i++){
		xx[i]=read(),yy[i]=read();
		maxn=max(maxn,max(xx[i],yy[i]));
	}
}
void work1(){
	flag[xst][yst]=1;
	for(int i=1;i<=n;i++){
		xst+=xx[i],yst+=yy[i];
		if(!flag[xst][yst]){ans++;flag[xst][yst]=1;}
		if(xst==xt&&yst==yt){cout<<ans<<endl;return ;}
		if(i==n){cout<<"SingleDogMZX"<<endl;return ;}
	}
}
void work2(){
	e[1].x=xst,e[1].y=yst;
	for(int i=1;i<=n;i++){
		xst+=xx[i],yst+=yy[i];
		ll noa=ans;
		for(int j=1;j<=noa;j++){
			if(e[j].x==xst&&e[j].y==yst)break;
			if(j==noa)e[++ans].x=xst,e[ans].y=yst;
		}
		if(xst==xt&&yst==yt){cout<<ans<<endl;return ;}
		if(i==n){cout<<"SingleDogMZX"<<endl;return ;}		
	}
}
int main(){
	freopen("loverfinding.in","r",stdin);
	freopen("loverfinding.out","w",stdout);
	init();
	if(maxn<=2500)work1();
	else work2();
	return 0;
}