#include<bits/stdc++.h>
#pragma GCC optimization("Ofast")
#pragma GCC target("avx2")
#pragma once
using namespace std;
typedef long long ll;
#define F first
#define S second
#define s second.first
#define T second.second
const ll mod=1e9+7;
int n, c[20];
pair<int, int> a1[3][150010];
pair<int, pair<int, int>> a[150010];
bitset<150010> b;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=0; i<n; i++){
cin >> a[i].F >> a[i].s >> a[i].T;
a1[0][i]={a[i].F, i};
a1[1][i]={a[i].s, i};
a1[2][i]={a[i].T, i};
}
sort(a1[0], a1[0]+n);
sort(a1[1], a1[1]+n);
sort(a1[2], a1[2]+n);
c[3]=-1;
c[0]=n-1;
c[1]=n-1;
c[2]=n-1;
while(c[0]>=0&&c[1]>=0&&c[2]>=0){
if(b[a1[0][c[0]].S])c[0]--;
else if(b[a1[1][c[1]].S])c[1]--;
else if(b[a1[2][c[2]].S])c[2]--;
else if(a[a1[0][c[0]].S].s==a1[1][c[1]].F||a[a1[0][c[0]].S].T==a1[2][c[2]].F)b[a1[0][c[0]].S]=1;
else if(a[a1[1][c[1]].S].F==a1[0][c[0]].F||a[a1[1][c[1]].S].T==a1[2][c[2]].F)b[a1[1][c[1]].S]=1;
else if(a[a1[2][c[2]].S].F==a1[0][c[0]].F||a[a1[2][c[2]].S].s==a1[1][c[1]].F)b[a1[2][c[2]].S]=1;
else{
c[3]=a1[0][c[0]].F+a1[1][c[1]].F+a1[2][c[2]].F;
break;
}
}
cout << c[3];
return 0;
}
Compilation message
team.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization("Ofast")
|
team.cpp:4:9: warning: #pragma once in main file
4 | #pragma once
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
324 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 |
0 ms |
332 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 |
328 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
324 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 |
0 ms |
332 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 |
328 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
328 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
420 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
600 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
2 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
61 ms |
6544 KB |
Output is correct |
12 |
Correct |
40 ms |
4444 KB |
Output is correct |
13 |
Correct |
42 ms |
5400 KB |
Output is correct |
14 |
Correct |
65 ms |
6476 KB |
Output is correct |
15 |
Correct |
57 ms |
6456 KB |
Output is correct |
16 |
Correct |
31 ms |
6372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
61 ms |
6544 KB |
Output is correct |
12 |
Correct |
40 ms |
4444 KB |
Output is correct |
13 |
Correct |
42 ms |
5400 KB |
Output is correct |
14 |
Correct |
65 ms |
6476 KB |
Output is correct |
15 |
Correct |
57 ms |
6456 KB |
Output is correct |
16 |
Correct |
31 ms |
6372 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
1 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 |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
67 ms |
6720 KB |
Output is correct |
23 |
Correct |
64 ms |
6328 KB |
Output is correct |
24 |
Correct |
51 ms |
4932 KB |
Output is correct |
25 |
Correct |
73 ms |
6736 KB |
Output is correct |
26 |
Correct |
62 ms |
6604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
61 ms |
6544 KB |
Output is correct |
12 |
Correct |
40 ms |
4444 KB |
Output is correct |
13 |
Correct |
42 ms |
5400 KB |
Output is correct |
14 |
Correct |
65 ms |
6476 KB |
Output is correct |
15 |
Correct |
57 ms |
6456 KB |
Output is correct |
16 |
Correct |
31 ms |
6372 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
1 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 |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
67 ms |
6720 KB |
Output is correct |
23 |
Correct |
64 ms |
6328 KB |
Output is correct |
24 |
Correct |
51 ms |
4932 KB |
Output is correct |
25 |
Correct |
73 ms |
6736 KB |
Output is correct |
26 |
Correct |
62 ms |
6604 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
328 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
68 ms |
6884 KB |
Output is correct |
35 |
Correct |
66 ms |
6444 KB |
Output is correct |
36 |
Correct |
72 ms |
7136 KB |
Output is correct |
37 |
Correct |
77 ms |
7228 KB |
Output is correct |
38 |
Correct |
61 ms |
7028 KB |
Output is correct |
39 |
Correct |
27 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
328 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
61 ms |
6544 KB |
Output is correct |
12 |
Correct |
40 ms |
4444 KB |
Output is correct |
13 |
Correct |
42 ms |
5400 KB |
Output is correct |
14 |
Correct |
65 ms |
6476 KB |
Output is correct |
15 |
Correct |
57 ms |
6456 KB |
Output is correct |
16 |
Correct |
31 ms |
6372 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
1 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 |
2 ms |
340 KB |
Output is correct |
22 |
Correct |
67 ms |
6720 KB |
Output is correct |
23 |
Correct |
64 ms |
6328 KB |
Output is correct |
24 |
Correct |
51 ms |
4932 KB |
Output is correct |
25 |
Correct |
73 ms |
6736 KB |
Output is correct |
26 |
Correct |
62 ms |
6604 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
328 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
340 KB |
Output is correct |
34 |
Correct |
68 ms |
6884 KB |
Output is correct |
35 |
Correct |
66 ms |
6444 KB |
Output is correct |
36 |
Correct |
72 ms |
7136 KB |
Output is correct |
37 |
Correct |
77 ms |
7228 KB |
Output is correct |
38 |
Correct |
61 ms |
7028 KB |
Output is correct |
39 |
Correct |
27 ms |
4444 KB |
Output is correct |
40 |
Correct |
2 ms |
472 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
1 ms |
468 KB |
Output is correct |
43 |
Correct |
3 ms |
424 KB |
Output is correct |
44 |
Correct |
73 ms |
7628 KB |
Output is correct |
45 |
Correct |
84 ms |
7828 KB |
Output is correct |
46 |
Correct |
79 ms |
7652 KB |
Output is correct |
47 |
Correct |
85 ms |
7756 KB |
Output is correct |
48 |
Correct |
66 ms |
7512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
320 KB |
Output is correct |
4 |
Correct |
1 ms |
324 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
376 KB |
Output is correct |
11 |
Correct |
0 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
324 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 |
0 ms |
332 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 |
328 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
328 KB |
Output is correct |
26 |
Correct |
2 ms |
596 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
2 ms |
596 KB |
Output is correct |
29 |
Correct |
3 ms |
596 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
3 ms |
420 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
600 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
340 KB |
Output is correct |
37 |
Correct |
1 ms |
468 KB |
Output is correct |
38 |
Correct |
2 ms |
468 KB |
Output is correct |
39 |
Correct |
1 ms |
340 KB |
Output is correct |
40 |
Correct |
0 ms |
340 KB |
Output is correct |
41 |
Correct |
1 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
0 ms |
328 KB |
Output is correct |
45 |
Correct |
0 ms |
340 KB |
Output is correct |
46 |
Correct |
1 ms |
340 KB |
Output is correct |
47 |
Correct |
1 ms |
328 KB |
Output is correct |
48 |
Correct |
0 ms |
340 KB |
Output is correct |
49 |
Correct |
1 ms |
340 KB |
Output is correct |
50 |
Correct |
61 ms |
6544 KB |
Output is correct |
51 |
Correct |
40 ms |
4444 KB |
Output is correct |
52 |
Correct |
42 ms |
5400 KB |
Output is correct |
53 |
Correct |
65 ms |
6476 KB |
Output is correct |
54 |
Correct |
57 ms |
6456 KB |
Output is correct |
55 |
Correct |
31 ms |
6372 KB |
Output is correct |
56 |
Correct |
0 ms |
256 KB |
Output is correct |
57 |
Correct |
1 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 |
2 ms |
340 KB |
Output is correct |
61 |
Correct |
67 ms |
6720 KB |
Output is correct |
62 |
Correct |
64 ms |
6328 KB |
Output is correct |
63 |
Correct |
51 ms |
4932 KB |
Output is correct |
64 |
Correct |
73 ms |
6736 KB |
Output is correct |
65 |
Correct |
62 ms |
6604 KB |
Output is correct |
66 |
Correct |
1 ms |
340 KB |
Output is correct |
67 |
Correct |
1 ms |
340 KB |
Output is correct |
68 |
Correct |
1 ms |
340 KB |
Output is correct |
69 |
Correct |
1 ms |
328 KB |
Output is correct |
70 |
Correct |
2 ms |
468 KB |
Output is correct |
71 |
Correct |
1 ms |
340 KB |
Output is correct |
72 |
Correct |
1 ms |
340 KB |
Output is correct |
73 |
Correct |
68 ms |
6884 KB |
Output is correct |
74 |
Correct |
66 ms |
6444 KB |
Output is correct |
75 |
Correct |
72 ms |
7136 KB |
Output is correct |
76 |
Correct |
77 ms |
7228 KB |
Output is correct |
77 |
Correct |
61 ms |
7028 KB |
Output is correct |
78 |
Correct |
27 ms |
4444 KB |
Output is correct |
79 |
Correct |
2 ms |
472 KB |
Output is correct |
80 |
Correct |
2 ms |
468 KB |
Output is correct |
81 |
Correct |
1 ms |
468 KB |
Output is correct |
82 |
Correct |
3 ms |
424 KB |
Output is correct |
83 |
Correct |
73 ms |
7628 KB |
Output is correct |
84 |
Correct |
84 ms |
7828 KB |
Output is correct |
85 |
Correct |
79 ms |
7652 KB |
Output is correct |
86 |
Correct |
85 ms |
7756 KB |
Output is correct |
87 |
Correct |
66 ms |
7512 KB |
Output is correct |
88 |
Correct |
77 ms |
9516 KB |
Output is correct |
89 |
Correct |
90 ms |
9496 KB |
Output is correct |
90 |
Correct |
82 ms |
9520 KB |
Output is correct |
91 |
Correct |
92 ms |
9480 KB |
Output is correct |
92 |
Correct |
75 ms |
8028 KB |
Output is correct |
93 |
Correct |
78 ms |
8308 KB |
Output is correct |
94 |
Correct |
77 ms |
8100 KB |
Output is correct |
95 |
Correct |
74 ms |
9288 KB |
Output is correct |
96 |
Correct |
76 ms |
9416 KB |
Output is correct |
97 |
Correct |
78 ms |
9528 KB |
Output is correct |
98 |
Correct |
42 ms |
8020 KB |
Output is correct |
99 |
Correct |
72 ms |
8040 KB |
Output is correct |