#include<bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std ;
const ll N = 2e5 ;
ll n, ans = -1, x[N + 1], y[N + 1], z[N + 1] ;
set<pair<ll, ll>> vx, vy, vz ;
signed main()
{
ios_base::sync_with_stdio( 0 ) ;
cin.tie( 0 ) ;
cout.tie( 0 ) ;
cin >> n ;
for(ll i = 1 ; i <= n ; i++)
{
cin >> x[i] >> y[i] >> z[i] ;
vx.insert({x[i], i}) ;
vy.insert({y[i], i}) ;
vz.insert({z[i], i}) ;
}
while(vx.size())
{
ll px = (*vx.rbegin()).se, py = (*vy.rbegin()).se, pz = (*vz.rbegin()).se ;
if(y[px] == y[py] || z[px] == z[pz])
{
vx.erase({x[px], px}) ;
vy.erase({y[px], px}) ;
vz.erase({z[px], px}) ;
continue ;
}
if(x[py] == x[px] || z[py] == z[pz])
{
vx.erase({x[py], py}) ;
vy.erase({y[py], py}) ;
vz.erase({z[py], py}) ;
continue ;
}
if(x[pz] == x[px] || y[pz] == y[py])
{
vx.erase({x[pz], pz}) ;
vy.erase({y[pz], pz}) ;
vz.erase({z[pz], pz}) ;
continue ;
}
ans = x[px] + y[py] + z[pz] ;
break ;
}
cout << ans ;
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
360 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
360 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
4 ms |
1108 KB |
Output is correct |
27 |
Correct |
6 ms |
1176 KB |
Output is correct |
28 |
Correct |
5 ms |
1088 KB |
Output is correct |
29 |
Correct |
5 ms |
1076 KB |
Output is correct |
30 |
Correct |
3 ms |
852 KB |
Output is correct |
31 |
Correct |
5 ms |
1108 KB |
Output is correct |
32 |
Correct |
4 ms |
1108 KB |
Output is correct |
33 |
Correct |
4 ms |
1108 KB |
Output is correct |
34 |
Correct |
3 ms |
1108 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
1108 KB |
Output is correct |
38 |
Correct |
3 ms |
1108 KB |
Output is correct |
39 |
Correct |
2 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
142 ms |
31900 KB |
Output is correct |
12 |
Correct |
130 ms |
21416 KB |
Output is correct |
13 |
Correct |
111 ms |
26300 KB |
Output is correct |
14 |
Correct |
181 ms |
32008 KB |
Output is correct |
15 |
Correct |
133 ms |
31948 KB |
Output is correct |
16 |
Correct |
130 ms |
32020 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
142 ms |
31900 KB |
Output is correct |
12 |
Correct |
130 ms |
21416 KB |
Output is correct |
13 |
Correct |
111 ms |
26300 KB |
Output is correct |
14 |
Correct |
181 ms |
32008 KB |
Output is correct |
15 |
Correct |
133 ms |
31948 KB |
Output is correct |
16 |
Correct |
130 ms |
32020 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Correct |
165 ms |
31976 KB |
Output is correct |
23 |
Correct |
173 ms |
31156 KB |
Output is correct |
24 |
Correct |
148 ms |
23152 KB |
Output is correct |
25 |
Correct |
285 ms |
32000 KB |
Output is correct |
26 |
Correct |
139 ms |
31948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
142 ms |
31900 KB |
Output is correct |
12 |
Correct |
130 ms |
21416 KB |
Output is correct |
13 |
Correct |
111 ms |
26300 KB |
Output is correct |
14 |
Correct |
181 ms |
32008 KB |
Output is correct |
15 |
Correct |
133 ms |
31948 KB |
Output is correct |
16 |
Correct |
130 ms |
32020 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Correct |
165 ms |
31976 KB |
Output is correct |
23 |
Correct |
173 ms |
31156 KB |
Output is correct |
24 |
Correct |
148 ms |
23152 KB |
Output is correct |
25 |
Correct |
285 ms |
32000 KB |
Output is correct |
26 |
Correct |
139 ms |
31948 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
0 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
360 KB |
Output is correct |
31 |
Correct |
4 ms |
1144 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
261 ms |
30460 KB |
Output is correct |
35 |
Correct |
257 ms |
29012 KB |
Output is correct |
36 |
Correct |
292 ms |
31956 KB |
Output is correct |
37 |
Correct |
358 ms |
31752 KB |
Output is correct |
38 |
Correct |
181 ms |
31196 KB |
Output is correct |
39 |
Correct |
84 ms |
19252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
142 ms |
31900 KB |
Output is correct |
12 |
Correct |
130 ms |
21416 KB |
Output is correct |
13 |
Correct |
111 ms |
26300 KB |
Output is correct |
14 |
Correct |
181 ms |
32008 KB |
Output is correct |
15 |
Correct |
133 ms |
31948 KB |
Output is correct |
16 |
Correct |
130 ms |
32020 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
340 KB |
Output is correct |
19 |
Correct |
0 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Correct |
165 ms |
31976 KB |
Output is correct |
23 |
Correct |
173 ms |
31156 KB |
Output is correct |
24 |
Correct |
148 ms |
23152 KB |
Output is correct |
25 |
Correct |
285 ms |
32000 KB |
Output is correct |
26 |
Correct |
139 ms |
31948 KB |
Output is correct |
27 |
Correct |
0 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
0 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
360 KB |
Output is correct |
31 |
Correct |
4 ms |
1144 KB |
Output is correct |
32 |
Correct |
1 ms |
468 KB |
Output is correct |
33 |
Correct |
1 ms |
468 KB |
Output is correct |
34 |
Correct |
261 ms |
30460 KB |
Output is correct |
35 |
Correct |
257 ms |
29012 KB |
Output is correct |
36 |
Correct |
292 ms |
31956 KB |
Output is correct |
37 |
Correct |
358 ms |
31752 KB |
Output is correct |
38 |
Correct |
181 ms |
31196 KB |
Output is correct |
39 |
Correct |
84 ms |
19252 KB |
Output is correct |
40 |
Correct |
3 ms |
852 KB |
Output is correct |
41 |
Correct |
3 ms |
1108 KB |
Output is correct |
42 |
Correct |
2 ms |
1108 KB |
Output is correct |
43 |
Correct |
3 ms |
1108 KB |
Output is correct |
44 |
Correct |
277 ms |
31900 KB |
Output is correct |
45 |
Correct |
365 ms |
32000 KB |
Output is correct |
46 |
Correct |
355 ms |
32008 KB |
Output is correct |
47 |
Correct |
404 ms |
31980 KB |
Output is correct |
48 |
Correct |
210 ms |
31972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
360 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
4 ms |
1108 KB |
Output is correct |
27 |
Correct |
6 ms |
1176 KB |
Output is correct |
28 |
Correct |
5 ms |
1088 KB |
Output is correct |
29 |
Correct |
5 ms |
1076 KB |
Output is correct |
30 |
Correct |
3 ms |
852 KB |
Output is correct |
31 |
Correct |
5 ms |
1108 KB |
Output is correct |
32 |
Correct |
4 ms |
1108 KB |
Output is correct |
33 |
Correct |
4 ms |
1108 KB |
Output is correct |
34 |
Correct |
3 ms |
1108 KB |
Output is correct |
35 |
Correct |
1 ms |
468 KB |
Output is correct |
36 |
Correct |
1 ms |
468 KB |
Output is correct |
37 |
Correct |
2 ms |
1108 KB |
Output is correct |
38 |
Correct |
3 ms |
1108 KB |
Output is correct |
39 |
Correct |
2 ms |
724 KB |
Output is correct |
40 |
Correct |
0 ms |
340 KB |
Output is correct |
41 |
Correct |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
0 ms |
340 KB |
Output is correct |
43 |
Correct |
0 ms |
340 KB |
Output is correct |
44 |
Correct |
0 ms |
212 KB |
Output is correct |
45 |
Correct |
0 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
0 ms |
340 KB |
Output is correct |
48 |
Correct |
0 ms |
212 KB |
Output is correct |
49 |
Correct |
1 ms |
340 KB |
Output is correct |
50 |
Correct |
142 ms |
31900 KB |
Output is correct |
51 |
Correct |
130 ms |
21416 KB |
Output is correct |
52 |
Correct |
111 ms |
26300 KB |
Output is correct |
53 |
Correct |
181 ms |
32008 KB |
Output is correct |
54 |
Correct |
133 ms |
31948 KB |
Output is correct |
55 |
Correct |
130 ms |
32020 KB |
Output is correct |
56 |
Correct |
0 ms |
212 KB |
Output is correct |
57 |
Correct |
0 ms |
340 KB |
Output is correct |
58 |
Correct |
0 ms |
340 KB |
Output is correct |
59 |
Correct |
1 ms |
340 KB |
Output is correct |
60 |
Correct |
1 ms |
724 KB |
Output is correct |
61 |
Correct |
165 ms |
31976 KB |
Output is correct |
62 |
Correct |
173 ms |
31156 KB |
Output is correct |
63 |
Correct |
148 ms |
23152 KB |
Output is correct |
64 |
Correct |
285 ms |
32000 KB |
Output is correct |
65 |
Correct |
139 ms |
31948 KB |
Output is correct |
66 |
Correct |
0 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
340 KB |
Output is correct |
68 |
Correct |
0 ms |
340 KB |
Output is correct |
69 |
Correct |
1 ms |
360 KB |
Output is correct |
70 |
Correct |
4 ms |
1144 KB |
Output is correct |
71 |
Correct |
1 ms |
468 KB |
Output is correct |
72 |
Correct |
1 ms |
468 KB |
Output is correct |
73 |
Correct |
261 ms |
30460 KB |
Output is correct |
74 |
Correct |
257 ms |
29012 KB |
Output is correct |
75 |
Correct |
292 ms |
31956 KB |
Output is correct |
76 |
Correct |
358 ms |
31752 KB |
Output is correct |
77 |
Correct |
181 ms |
31196 KB |
Output is correct |
78 |
Correct |
84 ms |
19252 KB |
Output is correct |
79 |
Correct |
3 ms |
852 KB |
Output is correct |
80 |
Correct |
3 ms |
1108 KB |
Output is correct |
81 |
Correct |
2 ms |
1108 KB |
Output is correct |
82 |
Correct |
3 ms |
1108 KB |
Output is correct |
83 |
Correct |
277 ms |
31900 KB |
Output is correct |
84 |
Correct |
365 ms |
32000 KB |
Output is correct |
85 |
Correct |
355 ms |
32008 KB |
Output is correct |
86 |
Correct |
404 ms |
31980 KB |
Output is correct |
87 |
Correct |
210 ms |
31972 KB |
Output is correct |
88 |
Correct |
312 ms |
31900 KB |
Output is correct |
89 |
Correct |
331 ms |
32016 KB |
Output is correct |
90 |
Correct |
296 ms |
31972 KB |
Output is correct |
91 |
Correct |
337 ms |
32016 KB |
Output is correct |
92 |
Correct |
323 ms |
31948 KB |
Output is correct |
93 |
Correct |
385 ms |
31948 KB |
Output is correct |
94 |
Correct |
369 ms |
32044 KB |
Output is correct |
95 |
Correct |
226 ms |
32184 KB |
Output is correct |
96 |
Correct |
198 ms |
31972 KB |
Output is correct |
97 |
Correct |
149 ms |
31948 KB |
Output is correct |
98 |
Correct |
136 ms |
31980 KB |
Output is correct |
99 |
Correct |
145 ms |
31892 KB |
Output is correct |