列表

详情


NC222874. IndustrialNuclearWater

描述

Giant Kingdom creates tons of drinkable water, and will discharge the water into an ocean. The ocean can be simplified to a 3-dimensional space. Because of some magic, there are 3 surfaces, , and water can't pass through any of the surfaces. Baby Kingdom is worried about whether the drinkable water can reach their country.

Given are two coordinates (x_1,y_1,z_1),(x_2,y_2,z_2) indicate the position of Giant Kingdom and the position of Baby Kingdom. Please find out weather the drinkable water can reach Baby Kingdom. It is guaranteed that both countries do not located in any of the surfaces.

You need to answer  queries.

输入描述

First line contains one integer  ().
Next  lines, the -th line contains 6 integers x_1,y_1,z_1,x_2,y_2,z_2 (), indicating the -th query.

输出描述

 lines, in the -th line print `Yes` if the drinkable water can reach Baby Kingdom, print `No` otherwise.

示例1

输入:

3
1 0 0 2 0 0
1 0 0 -1 0 0
1 0 0 1 1 0

输出:

Yes
No
No

说明:

In example, query 3, the surface divide(1,0,0),(1,1,0)_{} is 1000|y|=x^2+z^2.

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++ 解法, 执行用时: 3ms, 内存消耗: 384K, 提交时间: 2021-11-07 15:07:04

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int solve(ll x,ll y,ll z)
{
	return (1000*llabs(x)<y*y+z*z ? 2 : x>0) * 9
		+ (1000*llabs(y)<x*x+z*z ? 2 : y>0) * 3
		+ (1000*llabs(z)<x*x+y*y ? 2 : z>0);
}
int main()
{
	int cas; scanf("%d",&cas);
	while(cas--)
	{
		int x1,y1,z1,x2,y2,z2;
		scanf("%d%d%d%d%d%d",&x1,&y1,&z1,&x2,&y2,&z2);
		puts(solve(x1,y1,z1)==solve(x2,y2,z2) ? "Yes" : "No");
	}
}

上一题