记录编号 338605 评测结果 AAAAAAAAAT
题目名称 为爱追寻 最终得分 90
用户昵称 Gravatar__stdcall 是否通过 未通过
代码语言 C++ 运行时间 8.403 s
提交时间 2016-11-05 13:13:06 内存使用 103.27 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int mod = 10000007;

bool isdigit(char c) {
	return c >= '0' && c <= '9';
}

int getint(void) {
	char c = getchar();
	int sign = 1, num = 0;
	while(!isdigit(c) && c != '-') c = getchar();
	if(c == '-') {
		sign = -1;
		c = getchar();
	}
	while(isdigit(c)) {
		num = 10 * num + c - '0';
		c = getchar();
	}
	return sign * num;
}

struct point {
	int x, y;
};

bool operator == (const point &a, const point &b) {
	return a.x == b.x && a.y == b.y;
}

int h(const point &a) {
	return ((a.x % mod + a.y % mod * 17) % mod + mod) % mod;
}

vector<point> hash[mod];

int add(const point &a) {
	int key = h(a);
	for(vector<point>::iterator i = hash[key].begin(); i != hash[key].end(); i++) if(a == *i) return 0;
	hash[key].push_back(a);
	return 1;
}

int main(void) {
	freopen("loverfinding.in", "r", stdin);
	freopen("loverfinding.out", "w", stdout);
	int n, x0, y0, xt, yt, ans = 0;
	n = getint();
	x0 = getint();
	y0 = getint();
	xt = getint();
	yt = getint();
	point nowpos = (point){x0, y0}, target = (point){xt, yt};
	
	ans += add(nowpos);
	if(nowpos == target) goto SUCC;
	for(int i = 0; i < n; i++) {
		int dx, dy;
		dx = getint();
		dy = getint();
		nowpos.x += dx;
		nowpos.y += dy;
		ans += add(nowpos);
		if(nowpos == target) goto SUCC;
	}
	
	puts("SingleDogMZX"); return 0;
	SUCC: printf("%d\n", ans); return 0;
}