比赛 NOIP模拟赛by mzx Day1 评测结果 TTTTTTTTTT
题目名称 为爱追寻 最终得分 0
用户昵称 Theodore 运行时间 10.007 s
代码语言 C++ 内存使用 36.84 MiB
提交时间 2016-10-19 20:50:26
显示代码纯文本
  1. #include<queue>
  2. #include<cmath>
  3. #include<ctime>
  4. #include<cstdio>
  5. #include<cstdlib>
  6. #include<cstring>
  7. #include<iomanip>
  8. #include<iostream>
  9. #include<algorithm>
  10. using namespace std;
  11. #define ll long long
  12.  
  13. ll n,xst,yst,xt,yt,ans=1,maxn=0;
  14. ll xx[1000010],yy[1000010];
  15. bool flag[2510][2510]={};
  16. struct T{
  17. ll x,y;
  18. }e[1000010];
  19.  
  20. ll read(){
  21. char ch=getchar();ll x=0,f=1;
  22. while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  23. while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
  24. return x*f;
  25. }
  26. void init(){
  27. n=read(),xst=read(),yst=read(),xt=read(),yt=read();
  28. for(int i=1;i<=n;i++){
  29. xx[i]=read(),yy[i]=read();
  30. maxn=max(maxn,max(xx[i],yy[i]));
  31. }
  32. }
  33. void work1(){
  34. flag[xst][yst]=1;
  35. for(int i=1;i<=n;i++){
  36. xst+=xx[i],yst+=yy[i];
  37. if(!flag[xst][yst]){ans++;flag[xst][yst]=1;}
  38. if(xst==xt&&yst==yt){cout<<ans<<endl;return ;}
  39. if(i==n){cout<<"SingleDogMZX"<<endl;return ;}
  40. }
  41. }
  42. void work2(){
  43. e[1].x=xst,e[1].y=yst;
  44. for(int i=1;i<=n;i++){
  45. xst+=xx[i],yst+=yy[i];
  46. ll noa=ans;
  47. for(int j=1;j<=noa;j++){
  48. if(e[j].x==xst&&e[j].y==yst)break;
  49. if(j==noa)e[++ans].x=xst,e[ans].y=yst;
  50. }
  51. if(xst==xt&&yst==yt){cout<<ans<<endl;return ;}
  52. if(i==n){cout<<"SingleDogMZX"<<endl;return ;}
  53. }
  54. }
  55. int main(){
  56. freopen("loverfinding.in","r",stdin);
  57. freopen("loverfinding.out","w",stdout);
  58. init();
  59. if(maxn<=2500)work1();
  60. else work2();
  61. return 0;
  62. }