记录编号 |
441031 |
评测结果 |
AAAAAAAAAA |
题目名称 |
为爱追寻 |
最终得分 |
100 |
用户昵称 |
Super_Nick |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.795 s |
提交时间 |
2017-08-24 14:19:10 |
内存使用 |
43.33 MiB |
显示代码纯文本
#include<bits/stdc++.h>
#define N 1000010
#define base 2500
#define RG register
using namespace std;
struct node{
int dx,dy;
}mov[N];
struct note{
int x,y,tim;
}hha[N];
bool flag,vis[5010][5010];
map<pair<int,int>,bool> vi;
int n,dx,dy,x0,xt,y00,yt,ans,curx,cury,yes;
inline int gi(){
RG int x=0;RG bool flag=0;RG char c=getchar();
while((c<'0'||c>'9')&&c!='-') c=getchar();
if(c=='-') c=getchar(),flag=1;
while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return flag?-x:x;
}
inline bool cmp(RG note const &a,RG note const &b){
if(a.x==b.x) return a.y<b.y;
return a.x<b.x;
}
int main(){
freopen("loverfinding.in","r",stdin);
freopen("loverfinding.out","w",stdout);
n=gi();
x0=curx=gi();y00=cury=gi();xt=gi();yt=gi();
hha[0].x=curx;hha[0].y=cury;
if(curx<-2500||cury<-2500||curx>2500||cury>2500) flag=1;
for (RG int i=1;i<=n;++i){
mov[i].dx=gi();mov[i].dy=gi();curx+=mov[i].dx;cury+=mov[i].dy;
hha[i].x=curx;hha[i].y=cury;hha[i].tim=i;
if(curx==xt&&cury==yt&&!yes) yes=i;
if(curx<-2500||cury<-2500||curx>2500||cury>2500) flag=1;
}
if(!flag){
x0+=base;y00+=base;xt+=base;yt+=base;
vis[x0][y00]=1;++ans;
for (RG int i=1;i<=n;++i){
x0+=mov[i].dx;y00+=mov[i].dy;
if(!vis[x0][y00]) ++ans;
vis[x0][y00]=1;
if(x0==xt&&y00==yt) break;
}
if(!vis[xt][yt]) puts("SingleDog");
else printf("%d\n",ans);
}
else{
if(!yes){puts("SingleDog");return 0;}
sort(hha,hha+yes+1,cmp);
for (RG int i=0;i<=yes;++i)
if(i==0||hha[i].x!=hha[i-1].x||hha[i].y!=hha[i-1].y)
++ans;
printf("%d\n",ans);
}
return 0;
}