Codeforces 39D. Cubical Planet

本文最后更新于:1 年前

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

1
2
0 0 0
0 1 0

output

1
YES

Sample 2

Input

1
2
1 1 0
0 1 0

output

1
YES

Sample 3

Input

1
1 1 1

output

1
NO

code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#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";
}
//code by yxisme;
//code by zeitspeed;
//welcome to yxisme.com;

Codeforces 39D. Cubical Planet
https://zeitspeed.github.io/2022/11/15/Codeforces 39D. Cubical Planet/
作者
yxisme
发布于
2022年11月15日
许可协议