提交记录 16541


用户 题目 状态 得分 用时 内存 语言 代码长度
d0j1a_1701 noip17d. 【NOIP2017】奶酪 Accepted 100 33.702 ms 620 KB C++11 2.56 KB
提交时间 评测时间
2021-10-03 23:27:17 2021-10-03 23:27:23
#include <iostream>
#include <cstring>
#include <queue>
#include <list>
using namespace std;
//#define FIO
struct IO {
#ifdef FIO
	const static int BUFSIZE = 1 << 20;
	char buf[BUFSIZE], obuf[BUFSIZE], *p1, *p2, *pp;
	inline char gc() {
		return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUFSIZE, stdin), p1 == p2) ? EOF : *p1++;
	}
	inline void pc(char c) {
		if(pp - obuf == BUFSIZE)	fwrite(obuf, 1, BUFSIZE, stdout), pp = obuf;
		*pp = c, pp++;
	}
	IO() {
		p1 = buf, p2 = buf, pp = obuf;
	}
	~IO() {
		fwrite(obuf, 1, pp - obuf, stdout);
	}
#else
	inline char gc() {
		return getchar();
	}
	inline void pc(char c) {
		putchar(c);
	}
#endif
	template<typename Tp = int>
	inline Tp read() {
		Tp s = 0;
		int f = 1;
		char ch = gc();
		while(!isdigit(ch)) f = (ch == '-' ? -1 : 1), ch = gc();
		while(isdigit(ch))  s = s * 10 + (ch ^ 48), ch = gc();
		return s * f;
	}
	template<typename Tp>
	void read(Tp &x) {
		x = read();
	}
	template<typename Tp, typename... Ts>
	void read(Tp &x, Ts &...val) {
		x = read<Tp>();
		read(val...);
	}
	template<typename Tp>
	void write(Tp x) {
		if(x < 0)	pc('-'), x = -x;
		static char sta[20];
		int top = 0;
		do sta[top++] = x % 10 + '0', x /= 10;
		while(x);
		while(top)	pc(sta[--top]);
	}
	template<typename Tp, typename... Ts>
	void write(Tp x, Ts... val) {
		write(x);
		pc(' ');
		write(val...);
	}
	template<typename... Ts>
	void writeln(Ts... val) {
		write(val...);
		pc('\n');
	}
} io;
inline long long squ(const long long &x) {
	return x * x;
}
int t, n, h, r;
struct Node {
	int x, y, z;
	inline bool canGoThrough(Node other) {
		return (squ(x - other.x) + squ(y - other.y) + squ(z - other.z)) <= squ((long long)r << 1);
	}
} nodes[1010];
list<int> edges[1010];
bool vis[1010];
queue<int> q;
inline bool bfs() {
	while(q.size())	q.pop();
	memset(vis, false, sizeof(vis));
	for(int i = 1; i <= n; i++)
		if(nodes[i].z - r <= 0) {
			if(nodes[i].z + r >= h)	return true;
			q.push(i), vis[i] = true;
		}
	while(q.size()) {
		int u = q.front();
		q.pop();
		for(int to : edges[u]) {
			if(nodes[to].z + r >= h)	return true;
			if(!vis[to])
				q.push(to), vis[to] = true;
		}
	}
	return false;
}
void writeln(string str) {
	for(char ch : str)	io.pc(ch);
	io.pc('\n');
}
int main() {
	t = io.read();
	while(t--) {
		io.read(n, h, r);
		for(int i = 1; i <= n; i++)	edges[i].clear();
		for(int i = 1; i <= n; i++)	nodes[i] = {io.read(), io.read(), io.read()};
		for(int i = 1; i <= n; i++)
			for(int j = 1; j <= n; j++)
				if(i != j && nodes[i].canGoThrough(nodes[j]))
					edges[i].push_back(j);
		writeln(bfs() ? "Yes" : "No");
	}
	//system("pause");
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #141.55 us64 KBAcceptedScore: 10

Testcase #249.34 us64 KBAcceptedScore: 10

Testcase #348.43 us68 KBAcceptedScore: 10

Testcase #466.73 us68 KBAcceptedScore: 10

Testcase #58.473 ms284 KBAcceptedScore: 10

Testcase #617.156 ms320 KBAcceptedScore: 10

Testcase #733.702 ms620 KBAcceptedScore: 10

Testcase #830.203 ms376 KBAcceptedScore: 10

Testcase #932.013 ms432 KBAcceptedScore: 10

Testcase #1032.214 ms332 KBAcceptedScore: 10


Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:21:48 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠