답안 #997181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
997181 2024-06-11T19:31:55 Z vladilius Team Contest (JOI22_team) C++17
100 / 100
591 ms 76628 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
#define ins insert

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n; cin>>n;
    vector<int> x(n + 1), y(n + 1), z(n + 1);
    map<pii, vector<int>> mp1, mp2, mp3;
    vector<bool> ban(n + 1);
    int m = n;
    for (int i = 1; i <= n; i++){
        cin>>x[i]>>y[i]>>z[i];
        mp1[{x[i], y[i]}].pb(i);
        mp2[{x[i], z[i]}].pb(i);
        mp3[{y[i], z[i]}].pb(i);
    }
    
    multiset<int> sx, sy, sz;
    for (int i = 1; i <= n; i++){
        sx.ins(x[i]);
        sy.ins(y[i]);
        sz.ins(z[i]);
    }
    
    auto erase = [&](int i){
        ban[i] = 1; m--;
        sx.erase(sx.find(x[i]));
        sy.erase(sy.find(y[i]));
        sz.erase(sz.find(z[i]));
    };
    
    while (m >= 3){
        int f1 = *prev(sx.end()), f2 = *prev(sy.end()), f3 = *prev(sz.end());
        bool ind = 1;
        for (int j: mp1[{f1, f2}]){
            if (ban[j]) continue;
            ind = 0;
            erase(j);
        }
        for (int j: mp2[{f1, f3}]){
            if (ban[j]) continue;
            ind = 0;
            erase(j);
        }
        for (int j: mp3[{f2, f3}]){
            if (ban[j]) continue;
            ind = 0;
            erase(j);
        }
        
        if (ind){
            cout<<f1 + f2 + f3<<"\n";
            return 0;
        }
    }
    cout<<-1<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 5 ms 2140 KB Output is correct
27 Correct 6 ms 2140 KB Output is correct
28 Correct 6 ms 2396 KB Output is correct
29 Correct 7 ms 2392 KB Output is correct
30 Correct 4 ms 1628 KB Output is correct
31 Correct 5 ms 2396 KB Output is correct
32 Correct 5 ms 1884 KB Output is correct
33 Correct 4 ms 1628 KB Output is correct
34 Correct 6 ms 2140 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 4 ms 1884 KB Output is correct
38 Correct 4 ms 1884 KB Output is correct
39 Correct 2 ms 856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 143 ms 25396 KB Output is correct
12 Correct 107 ms 17204 KB Output is correct
13 Correct 84 ms 20672 KB Output is correct
14 Correct 154 ms 25428 KB Output is correct
15 Correct 122 ms 25144 KB Output is correct
16 Correct 118 ms 25012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 143 ms 25396 KB Output is correct
12 Correct 107 ms 17204 KB Output is correct
13 Correct 84 ms 20672 KB Output is correct
14 Correct 154 ms 25428 KB Output is correct
15 Correct 122 ms 25144 KB Output is correct
16 Correct 118 ms 25012 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 165 ms 25756 KB Output is correct
23 Correct 169 ms 24912 KB Output is correct
24 Correct 138 ms 18768 KB Output is correct
25 Correct 198 ms 25808 KB Output is correct
26 Correct 133 ms 25264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 143 ms 25396 KB Output is correct
12 Correct 107 ms 17204 KB Output is correct
13 Correct 84 ms 20672 KB Output is correct
14 Correct 154 ms 25428 KB Output is correct
15 Correct 122 ms 25144 KB Output is correct
16 Correct 118 ms 25012 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 165 ms 25756 KB Output is correct
23 Correct 169 ms 24912 KB Output is correct
24 Correct 138 ms 18768 KB Output is correct
25 Correct 198 ms 25808 KB Output is correct
26 Correct 133 ms 25264 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 6 ms 1884 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 388 ms 45696 KB Output is correct
35 Correct 346 ms 40448 KB Output is correct
36 Correct 389 ms 40936 KB Output is correct
37 Correct 384 ms 40016 KB Output is correct
38 Correct 162 ms 26556 KB Output is correct
39 Correct 101 ms 26092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 143 ms 25396 KB Output is correct
12 Correct 107 ms 17204 KB Output is correct
13 Correct 84 ms 20672 KB Output is correct
14 Correct 154 ms 25428 KB Output is correct
15 Correct 122 ms 25144 KB Output is correct
16 Correct 118 ms 25012 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 165 ms 25756 KB Output is correct
23 Correct 169 ms 24912 KB Output is correct
24 Correct 138 ms 18768 KB Output is correct
25 Correct 198 ms 25808 KB Output is correct
26 Correct 133 ms 25264 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 6 ms 1884 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 388 ms 45696 KB Output is correct
35 Correct 346 ms 40448 KB Output is correct
36 Correct 389 ms 40936 KB Output is correct
37 Correct 384 ms 40016 KB Output is correct
38 Correct 162 ms 26556 KB Output is correct
39 Correct 101 ms 26092 KB Output is correct
40 Correct 4 ms 1628 KB Output is correct
41 Correct 5 ms 2396 KB Output is correct
42 Correct 3 ms 1928 KB Output is correct
43 Correct 4 ms 1884 KB Output is correct
44 Correct 443 ms 74460 KB Output is correct
45 Correct 537 ms 61264 KB Output is correct
46 Correct 473 ms 65332 KB Output is correct
47 Correct 534 ms 59948 KB Output is correct
48 Correct 197 ms 28948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 600 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 5 ms 2140 KB Output is correct
27 Correct 6 ms 2140 KB Output is correct
28 Correct 6 ms 2396 KB Output is correct
29 Correct 7 ms 2392 KB Output is correct
30 Correct 4 ms 1628 KB Output is correct
31 Correct 5 ms 2396 KB Output is correct
32 Correct 5 ms 1884 KB Output is correct
33 Correct 4 ms 1628 KB Output is correct
34 Correct 6 ms 2140 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 4 ms 1884 KB Output is correct
38 Correct 4 ms 1884 KB Output is correct
39 Correct 2 ms 856 KB Output is correct
40 Correct 0 ms 344 KB Output is correct
41 Correct 0 ms 344 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 344 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 143 ms 25396 KB Output is correct
51 Correct 107 ms 17204 KB Output is correct
52 Correct 84 ms 20672 KB Output is correct
53 Correct 154 ms 25428 KB Output is correct
54 Correct 122 ms 25144 KB Output is correct
55 Correct 118 ms 25012 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 860 KB Output is correct
61 Correct 165 ms 25756 KB Output is correct
62 Correct 169 ms 24912 KB Output is correct
63 Correct 138 ms 18768 KB Output is correct
64 Correct 198 ms 25808 KB Output is correct
65 Correct 133 ms 25264 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 6 ms 1884 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 2 ms 604 KB Output is correct
73 Correct 388 ms 45696 KB Output is correct
74 Correct 346 ms 40448 KB Output is correct
75 Correct 389 ms 40936 KB Output is correct
76 Correct 384 ms 40016 KB Output is correct
77 Correct 162 ms 26556 KB Output is correct
78 Correct 101 ms 26092 KB Output is correct
79 Correct 4 ms 1628 KB Output is correct
80 Correct 5 ms 2396 KB Output is correct
81 Correct 3 ms 1928 KB Output is correct
82 Correct 4 ms 1884 KB Output is correct
83 Correct 443 ms 74460 KB Output is correct
84 Correct 537 ms 61264 KB Output is correct
85 Correct 473 ms 65332 KB Output is correct
86 Correct 534 ms 59948 KB Output is correct
87 Correct 197 ms 28948 KB Output is correct
88 Correct 438 ms 76628 KB Output is correct
89 Correct 501 ms 74576 KB Output is correct
90 Correct 466 ms 76220 KB Output is correct
91 Correct 591 ms 73104 KB Output is correct
92 Correct 497 ms 73556 KB Output is correct
93 Correct 561 ms 73572 KB Output is correct
94 Correct 569 ms 69972 KB Output is correct
95 Correct 315 ms 52416 KB Output is correct
96 Correct 364 ms 76400 KB Output is correct
97 Correct 126 ms 28852 KB Output is correct
98 Correct 171 ms 58820 KB Output is correct
99 Correct 244 ms 58708 KB Output is correct