#include <iostream>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <iterator>
using namespace std;
int main() {
int N;
cin >> N; // Read the number of points
cin.ignore(); // Ignore the newline after reading N
// Vectors to store the coordinates
vector<int> X(N), Y(N), Z(N);
// Read the X coordinates
for (int i = 0; i < N; ++i) {
cin >> X[i];
}
cin.ignore(); // Ignore the newline after reading X
// Read the Y coordinates
for (int i = 0; i < N; ++i) {
cin >> Y[i];
}
cin.ignore(); // Ignore the newline after reading Y
// Read the Z coordinates
for (int i = 0; i < N; ++i) {
cin >> Z[i];
}
// Set to hold unique positions
set<tuple<int, int, int>> poses;
// Populate the set with the tuples
for (int i = 0; i < N; ++i) {
poses.insert(make_tuple(X[i], Y[i], Z[i]));
}
// Check the movement between positions
for (auto from_pos = poses.begin(); from_pos != poses.end(); ++from_pos) {
for (auto to_pos = next(from_pos); to_pos != poses.end(); ++to_pos) {
vector<int> ghost_pos = {get<0>(*from_pos), get<1>(*from_pos), get<2>(*from_pos)};
vector<int> dirs = {
(get<0>(*to_pos) > ghost_pos[0]) - (get<0>(*to_pos) < ghost_pos[0]),
(get<1>(*to_pos) > ghost_pos[1]) - (get<1>(*to_pos) < ghost_pos[1]),
(get<2>(*to_pos) > ghost_pos[2]) - (get<2>(*to_pos) < ghost_pos[2])
};
// Continue moving the ghost until it reaches the destination
while (ghost_pos != vector<int>{get<0>(*to_pos), get<1>(*to_pos), get<2>(*to_pos)}) {
bool moved = false;
for (int axis = 0; axis < 3; ++axis) {
// Use get with a constant index
if (ghost_pos[axis] != (axis == 0 ? get<0>(*to_pos) : (axis == 1 ? get<1>(*to_pos) : get<2>(*to_pos)))) {
vector<int> next_pos = ghost_pos;
next_pos[axis] += dirs[axis];
if (poses.count(make_tuple(next_pos[0], next_pos[1], next_pos[2]))) {
ghost_pos[axis] += dirs[axis];
moved = true;
break;
}
}
}
if (!moved) {
cout << "NO" << endl;
return 0; // Exit on failure
}
}
}
}
cout << "YES" << endl;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 1ms | 320 KiB | ||||
2 | Accepted | 1ms | 320 KiB | ||||
3 | Accepted | 1ms | 320 KiB | ||||
subtask2 | 18/18 | ||||||
4 | Accepted | 1ms | 320 KiB | ||||
5 | Accepted | 1ms | 320 KiB | ||||
6 | Accepted | 14ms | 320 KiB | ||||
7 | Accepted | 4ms | 320 KiB | ||||
8 | Accepted | 3ms | 320 KiB | ||||
9 | Accepted | 1ms | 512 KiB | ||||
10 | Accepted | 4ms | 320 KiB | ||||
11 | Accepted | 3ms | 412 KiB | ||||
12 | Accepted | 1ms | 508 KiB | ||||
13 | Accepted | 2ms | 320 KiB | ||||
subtask3 | 0/19 | ||||||
14 | Accepted | 8ms | 724 KiB | ||||
15 | Accepted | 79ms | 500 KiB | ||||
16 | Accepted | 7ms | 824 KiB | ||||
17 | Accepted | 1.748s | 944 KiB | ||||
18 | Time limit exceeded | 3.091s | 824 KiB | ||||
19 | Time limit exceeded | 3.092s | 824 KiB | ||||
20 | Accepted | 1ms | 320 KiB | ||||
21 | Accepted | 19ms | 568 KiB | ||||
22 | Accepted | 8ms | 824 KiB | ||||
23 | Accepted | 2.387s | 960 KiB | ||||
24 | Time limit exceeded | 3.085s | 824 KiB | ||||
25 | Accepted | 21ms | 824 KiB | ||||
26 | Accepted | 1ms | 320 KiB | ||||
subtask4 | 0/24 | ||||||
27 | Accepted | 116ms | 7748 KiB | ||||
28 | Time limit exceeded | 3.085s | 420 KiB | ||||
29 | Time limit exceeded | 3.085s | 7736 KiB | ||||
30 | Time limit exceeded | 3.085s | 7748 KiB | ||||
31 | Time limit exceeded | 3.086s | 7736 KiB | ||||
32 | Time limit exceeded | 3.085s | 7736 KiB | ||||
33 | Accepted | 114ms | 320 KiB | ||||
34 | Time limit exceeded | 3.085s | 7748 KiB | ||||
35 | Time limit exceeded | 3.079s | 7736 KiB | ||||
36 | Time limit exceeded | 3.082s | 7744 KiB | ||||
37 | Time limit exceeded | 3.078s | 7736 KiB | ||||
38 | Accepted | 116ms | 7740 KiB | ||||
39 | Accepted | 97ms | 760 KiB | ||||
subtask5 | 0/22 | ||||||
40 | Accepted | 126ms | 7732 KiB | ||||
41 | Accepted | 94ms | 320 KiB | ||||
42 | Accepted | 32ms | 2540 KiB | ||||
43 | Accepted | 172ms | 7480 KiB | ||||
44 | Time limit exceeded | 3.086s | 7740 KiB | ||||
45 | Time limit exceeded | 3.072s | 7736 KiB | ||||
46 | Accepted | 1ms | 416 KiB | ||||
47 | Accepted | 39ms | 416 KiB | ||||
48 | Accepted | 63ms | 1848 KiB | ||||
49 | Time limit exceeded | 3.099s | 6968 KiB | ||||
50 | Accepted | 114ms | 7736 KiB | ||||
51 | Time limit exceeded | 3.085s | 7732 KiB | ||||
52 | Accepted | 114ms | 7736 KiB | ||||
53 | Accepted | 2ms | 320 KiB | ||||
subtask6 | 0/17 | ||||||
54 | Accepted | 156ms | 7732 KiB | ||||
55 | Time limit exceeded | 3.084s | 7736 KiB | ||||
56 | Accepted | 222ms | 7740 KiB | ||||
57 | Accepted | 477ms | 7736 KiB | ||||
58 | Time limit exceeded | 3.079s | 7736 KiB | ||||
59 | Time limit exceeded | 3.081s | 7736 KiB | ||||
60 | Time limit exceeded | 3.089s | 7736 KiB | ||||
61 | Accepted | 247ms | 7736 KiB | ||||
62 | Accepted | 279ms | 7736 KiB | ||||
63 | Time limit exceeded | 3.092s | 7736 KiB | ||||
64 | Time limit exceeded | 3.099s | 7736 KiB | ||||
65 | Accepted | 935ms | 7736 KiB | ||||
66 | Time limit exceeded | 3.099s | 7736 KiB |