记录编号 327001 评测结果 TTTWWWWWWT
题目名称 为爱追寻 最终得分 0
用户昵称 Gravatar悟理 是否通过 未通过
代码语言 C++ 运行时间 8.893 s
提交时间 2016-10-21 18:53:30 内存使用 0.28 MiB
显示代码纯文本
#include <iostream>
#include <fstream>
#include <cstdio>
#include <set>

using namespace std;

#define aha 0x40000000

inline long long GetInt(FILE *fin);
inline unsigned long long Pack_Coor(long long x,long long y);

FILE *fin = fopen("loverfinding.in","r"), *fout = fopen("loverfinding.out","w");

int main()
{
	int DataSize = GetInt(fin);
	long long px = GetInt(fin),py = GetInt(fin), dest_x = GetInt(fin), dest_y = GetInt(fin);
	unsigned long long P = Pack_Coor(px,py), dest = Pack_Coor(dest_x,dest_y);
	bool flag = true;
	set<unsigned long long>desks;
	
	//cout << Pack_Coor(2,3) << " " << dest << endl;
	
	for (int i = 1;i <= DataSize;++i)
	{
		desks.insert(P);
		px += GetInt(fin);py += GetInt(fin);
		P = Pack_Coor(px,py);
		//cout << (P >> 32) << " " << ((P << 32) >> 32) << " " << (dest >> 32) << " " << ((dest << 32) >> 32) << endl << endl;
		if (P == dest)
			flag = false;
	}
	
	fprintf(fout,"%lld\n",desks.size());
	if (flag)
		fprintf(fout,"SingleDogMZX\n");
	
	return 0;
}

inline long long GetInt(FILE *fin)
{
	long long num = 0;
	bool flag = false;
	char ch;
	ch = fgetc(fin);
	while (!(ch - ' ' && ch - '\n'))
		ch = fgetc(fin);
	if (!(ch - '-'))
	{
		flag = true;
		ch = fgetc(fin);
	}
	while ('0' <= ch && ch <= '9')
	{
		num = (num << 3) + (num << 1) + ch - '0';
		ch = fgetc(fin);
	}
	if (flag)
		return ~num + 1;
	else
		return num;
}

inline unsigned long long Pack_Coor(long long x,long long y)
{
	unsigned long long x1 = x,y1 = y;
	if (x < 0)
		x1 = (~x + 1) ^ aha;
	if (y < 0)
		y1 = (~y + 1) ^ aha;
	return (x1 << 32) ^ y1;
}