比赛 NOIP模拟赛by mzx Day1 评测结果 TTTTTTTTTT
题目名称 为爱追寻 最终得分 0
用户昵称 Tiny 运行时间 10.040 s
代码语言 C++ 内存使用 135.27 MiB
提交时间 2016-10-19 20:56:53
显示代码纯文本
#include <stdio.h>
#include <set>

#define fastcall __attribute__((optimize("-O2")))
#define Inline __inline__ __attribute__((always_inline))

const int MAXS = 150 * 1024 * 1024;
int buf_cnt = 0;
char read_buf[MAXS];

template <typename T> inline void Read_buf(T &num) {
	num = 0; bool minus = false;
	while (read_buf[buf_cnt] < '-' || read_buf[buf_cnt] > '9') ++buf_cnt;
	if (read_buf[buf_cnt] == '-') { minus = true; ++buf_cnt; }
	while (read_buf[buf_cnt] >= '0' && read_buf[buf_cnt] <= '9')
		num = num * 10 + read_buf[buf_cnt++] - '0';
	if (minus) num = -num;
}

template <typename T> inline void Read(T &num) {
	num = 0; char ch; bool minus = false;
	while (ch = getchar(), ch < '-' || ch > '9');
	if (ch == '-') { minus = true; ch = getchar(); }
	while (num = num * 10 + ch - '0', ch = getchar(), ch >= '0' && ch <= '9');
	if (minus) num = -num;
}

struct Point {
	int x, y;

	fastcall Inline Point() { Read_buf(this->x); Read_buf(this->y); }

	fastcall Inline Point(const int &_x, const int &_y): x(_x), y(_y) {}

	fastcall Inline Point operator +=(const Point &b) { return Point(this->x += b.x, this->y += b.y); }

	fastcall Inline bool operator ==(const Point &b) { return (this->x == b.x && this->y == b.y); }

	fastcall Inline bool operator <(const Point &b) const { return (x < b.x || (x == b.x && y < b.y)); }
};
std::set<Point> S;

int n;

fastcall Inline void Work(Point &s, const Point &t) {
	S.insert(s);
	for (int tot = 1; n--; ) {
		if (!S.count(s += Point())) { S.insert(s); ++tot; }
		if (s == t) { printf("%d\n", tot); return; }
	}
	printf("SingleDogMZX\n");
}

fastcall int main() {
 #define SUBMIT
 #ifdef SUBMIT
	freopen("loverfinding.in", "r", stdin);
	freopen("loverfinding.out", "w", stdout);
	fread(read_buf, 1, MAXS, stdin);
 #endif

	Read_buf(n);
	Point s, t;
	if (s == t) printf("1\n");
	else Work(s, t);

 #ifndef SUBMIT
	puts("\n--------------------");
	getchar(); getchar();
 #else
	fclose(stdin); fclose(stdout);
 #endif
	return 0;
}