답안 #938442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938442 2024-03-05T06:41:41 Z Regulus Team Contest (JOI22_team) C++17
100 / 100
109 ms 19908 KB
#define TEST
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#ifdef TEST
    #define debug(x) cerr << #x << " = " << (x) << ' '
    #define bug(x) cerr << (x) << ' '
    #define endl cerr << '\n'
#else
    #define debug(x) cout << ""
    #define bug(x) cout << ""
    #define endl cout << ""
#endif
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const int N = 2e5+5;
int x[N], y[N], z[N];
bool del[N];
priority_queue<pll> pq, pq2, pq3;

int main(void)
{ IO
    int n, i;

    cin >> n;
    for (i=1; i <= n; ++i)
    {
        cin >> x[i] >> y[i] >> z[i];
        pq.push({x[i], i});
        pq2.push({y[i], i});
        pq3.push({z[i], i});
    }

    while (!pq.empty() && !pq2.empty() && !pq3.empty())
    {
        while (!pq.empty() && del[pq.top().S]) pq.pop();
        while (!pq2.empty() && del[pq2.top().S]) pq2.pop();
        while (!pq3.empty() && del[pq3.top().S]) pq3.pop();
        if (pq.empty() || pq2.empty() || pq3.empty()) break;

        int a = pq.top().S, b = pq2.top().S, c = pq3.top().S;
        if (y[a] == y[b] || z[a] == z[c]) del[a] = 1;
        if (x[b] == x[a] || z[b] == z[c]) del[b] = 1;
        if (x[c] == x[a] || y[c] == y[b]) del[c] = 1;

        if (!del[a] && !del[b] && !del[c])
        {
            cout << x[a] + y[b] + z[c] << '\n';
            exit(0);
        }
    }

    cout << "-1\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2392 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2648 KB Output is correct
28 Correct 3 ms 2648 KB Output is correct
29 Correct 3 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2784 KB Output is correct
32 Correct 3 ms 2780 KB Output is correct
33 Correct 3 ms 2688 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 44 ms 14536 KB Output is correct
12 Correct 39 ms 7784 KB Output is correct
13 Correct 29 ms 9304 KB Output is correct
14 Correct 80 ms 13984 KB Output is correct
15 Correct 75 ms 14256 KB Output is correct
16 Correct 60 ms 15524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 44 ms 14536 KB Output is correct
12 Correct 39 ms 7784 KB Output is correct
13 Correct 29 ms 9304 KB Output is correct
14 Correct 80 ms 13984 KB Output is correct
15 Correct 75 ms 14256 KB Output is correct
16 Correct 60 ms 15524 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 35 ms 14504 KB Output is correct
23 Correct 42 ms 14244 KB Output is correct
24 Correct 46 ms 8620 KB Output is correct
25 Correct 86 ms 12952 KB Output is correct
26 Correct 73 ms 15776 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 44 ms 14536 KB Output is correct
12 Correct 39 ms 7784 KB Output is correct
13 Correct 29 ms 9304 KB Output is correct
14 Correct 80 ms 13984 KB Output is correct
15 Correct 75 ms 14256 KB Output is correct
16 Correct 60 ms 15524 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 35 ms 14504 KB Output is correct
23 Correct 42 ms 14244 KB Output is correct
24 Correct 46 ms 8620 KB Output is correct
25 Correct 86 ms 12952 KB Output is correct
26 Correct 73 ms 15776 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 3 ms 2652 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 37 ms 16720 KB Output is correct
35 Correct 52 ms 14756 KB Output is correct
36 Correct 56 ms 13748 KB Output is correct
37 Correct 106 ms 17316 KB Output is correct
38 Correct 76 ms 16388 KB Output is correct
39 Correct 46 ms 7820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 44 ms 14536 KB Output is correct
12 Correct 39 ms 7784 KB Output is correct
13 Correct 29 ms 9304 KB Output is correct
14 Correct 80 ms 13984 KB Output is correct
15 Correct 75 ms 14256 KB Output is correct
16 Correct 60 ms 15524 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2652 KB Output is correct
22 Correct 35 ms 14504 KB Output is correct
23 Correct 42 ms 14244 KB Output is correct
24 Correct 46 ms 8620 KB Output is correct
25 Correct 86 ms 12952 KB Output is correct
26 Correct 73 ms 15776 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 3 ms 2652 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 37 ms 16720 KB Output is correct
35 Correct 52 ms 14756 KB Output is correct
36 Correct 56 ms 13748 KB Output is correct
37 Correct 106 ms 17316 KB Output is correct
38 Correct 76 ms 16388 KB Output is correct
39 Correct 46 ms 7820 KB Output is correct
40 Correct 2 ms 2652 KB Output is correct
41 Correct 2 ms 2652 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2652 KB Output is correct
44 Correct 39 ms 15804 KB Output is correct
45 Correct 93 ms 17320 KB Output is correct
46 Correct 75 ms 13988 KB Output is correct
47 Correct 101 ms 17052 KB Output is correct
48 Correct 82 ms 17020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 1 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2516 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 2 ms 2392 KB Output is correct
26 Correct 2 ms 2652 KB Output is correct
27 Correct 2 ms 2648 KB Output is correct
28 Correct 3 ms 2648 KB Output is correct
29 Correct 3 ms 2652 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 2 ms 2784 KB Output is correct
32 Correct 3 ms 2780 KB Output is correct
33 Correct 3 ms 2688 KB Output is correct
34 Correct 2 ms 2652 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 2 ms 2652 KB Output is correct
38 Correct 2 ms 2652 KB Output is correct
39 Correct 1 ms 2652 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2396 KB Output is correct
43 Correct 1 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 0 ms 2396 KB Output is correct
47 Correct 1 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 44 ms 14536 KB Output is correct
51 Correct 39 ms 7784 KB Output is correct
52 Correct 29 ms 9304 KB Output is correct
53 Correct 80 ms 13984 KB Output is correct
54 Correct 75 ms 14256 KB Output is correct
55 Correct 60 ms 15524 KB Output is correct
56 Correct 1 ms 2396 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 2396 KB Output is correct
59 Correct 1 ms 2396 KB Output is correct
60 Correct 1 ms 2652 KB Output is correct
61 Correct 35 ms 14504 KB Output is correct
62 Correct 42 ms 14244 KB Output is correct
63 Correct 46 ms 8620 KB Output is correct
64 Correct 86 ms 12952 KB Output is correct
65 Correct 73 ms 15776 KB Output is correct
66 Correct 1 ms 2396 KB Output is correct
67 Correct 1 ms 2396 KB Output is correct
68 Correct 1 ms 2396 KB Output is correct
69 Correct 1 ms 2392 KB Output is correct
70 Correct 3 ms 2652 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 2396 KB Output is correct
73 Correct 37 ms 16720 KB Output is correct
74 Correct 52 ms 14756 KB Output is correct
75 Correct 56 ms 13748 KB Output is correct
76 Correct 106 ms 17316 KB Output is correct
77 Correct 76 ms 16388 KB Output is correct
78 Correct 46 ms 7820 KB Output is correct
79 Correct 2 ms 2652 KB Output is correct
80 Correct 2 ms 2652 KB Output is correct
81 Correct 2 ms 2652 KB Output is correct
82 Correct 2 ms 2652 KB Output is correct
83 Correct 39 ms 15804 KB Output is correct
84 Correct 93 ms 17320 KB Output is correct
85 Correct 75 ms 13988 KB Output is correct
86 Correct 101 ms 17052 KB Output is correct
87 Correct 82 ms 17020 KB Output is correct
88 Correct 54 ms 19232 KB Output is correct
89 Correct 78 ms 17568 KB Output is correct
90 Correct 54 ms 19536 KB Output is correct
91 Correct 109 ms 19056 KB Output is correct
92 Correct 69 ms 15044 KB Output is correct
93 Correct 90 ms 16184 KB Output is correct
94 Correct 101 ms 16412 KB Output is correct
95 Correct 87 ms 18252 KB Output is correct
96 Correct 93 ms 15272 KB Output is correct
97 Correct 76 ms 19908 KB Output is correct
98 Correct 46 ms 18440 KB Output is correct
99 Correct 71 ms 18256 KB Output is correct