Codeforces 39D. Cubical Planet

这篇博客讲述了在Codeforces 39D Cubical Planet问题中,如何通过坐标系统判断两只飞虫能否看到彼此,如果它们位于同一正方体面则能看到。输入是两组三维坐标,输出为“YES”或“NO”。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Codeforces 39D. Cubical Planet

You can find anything whatsoever in our Galaxy! A cubical planet goes round an icosahedral star. Let us introduce a system of axes so that the edges of the cubical planet are parallel to the coordinate axes and two opposite vertices lay in the points (0, 0, 0) and (1, 1, 1). Two flies live on the planet. At the moment they are sitting on two different vertices of the cubical planet. Your task is to determine whether they see each other or not. The flies see each other when the vertices they occupy lie on the same face of the cube.

InputThe first line contains three space-separated integers (0 or 1) — the coordinates of the first fly, the second line analogously contains the coordinates of the second fly.

OutputOutput “YES” (without quotes) if the flies see each other. Otherwise, output “NO”.

Sample 1

Input

0 0 0
0 1 0

output

YES

Sample 2

Input

1 1 0
0 1 0

output

YES

Sample 3

Input

1 1 1

output

NO

code


#include<bits/stdc++.h>
using namespace std;
int main(void){
    int a[7];
    for(int i=1;i<=6;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=1;i<=3;i++){
        if(a[i]==a[i+3]){
            sum++;
        }
    }
    if(sum>=1)cout<<"YES";
    else cout<<"NO";
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值