답안 #768400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
768400 2023-06-28T05:05:57 Z nguyentunglam Team Contest (JOI22_team) C++17
100 / 100
481 ms 62876 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2e5 + 10;
int x[N], y[N], z[N];
map<pair<int, int>, vector<int> > m[3];
bool ban[N];
int X, Y, Z;
vector<ii> vx, vy, vz;
int main() {
    #define task ""
    cin.tie(0) -> sync_with_stdio(0);
    if (fopen ("task.inp", "r")) {
        freopen ("task.inp", "r", stdin);
        freopen ("task.out", "w", stdout);
    }
    if (fopen (task".inp", "r")) {
        freopen (task".inp", "r", stdin);
        freopen (task".out", "w", stdout);
    }
    int n; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i] >> z[i];
        vx.emplace_back(x[i], i);
        vy.emplace_back(y[i], i);
        vz.emplace_back(z[i], i);
        m[0][{x[i], y[i]}].push_back(i);
        m[1][{y[i], z[i]}].push_back(i);
        m[2][{x[i], z[i]}].push_back(i);
    }


    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    sort(vz.begin(), vz.end());

    int cur = n;

    while (cur >= 3) {
        while (ban[vx.back().se]) vx.pop_back();
        while (ban[vy.back().se]) vy.pop_back();
        while (ban[vz.back().se]) vz.pop_back();
        if (vx.empty() || vy.empty() || vz.empty()) break;
        X = vx.back().first;
        Y = vy.back().first;
        Z = vz.back().first;
        int pre = cur;
        for(int &j : m[0][{X, Y}]) if (ban[j] == 0) {
            cur--; ban[j] = 1;
        }
        for(int &j : m[1][{Y, Z}]) if (ban[j] == 0) {
            cur--; ban[j] = 1;
        }
        for(int &j : m[2][{X, Z}]) if (ban[j] == 0) {
            cur--; ban[j] = 1;
        }
        m[0][{X, Y}].clear();
        m[1][{Y, Z}].clear();
        m[2][{X, Z}].clear();
        if (pre == cur) return cout << X + Y + Z, 0;
    }
    cout << -1;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:17:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen ("task.inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:18:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen ("task.out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:21:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen (task".inp", "r", stdin);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:22:17: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen (task".out", "w", stdout);
      |         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 468 KB Output is correct
18 Correct 1 ms 468 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 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 468 KB Output is correct
18 Correct 1 ms 468 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 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 1776 KB Output is correct
27 Correct 5 ms 1748 KB Output is correct
28 Correct 6 ms 1748 KB Output is correct
29 Correct 7 ms 1844 KB Output is correct
30 Correct 4 ms 1364 KB Output is correct
31 Correct 5 ms 1748 KB Output is correct
32 Correct 5 ms 1412 KB Output is correct
33 Correct 3 ms 1108 KB Output is correct
34 Correct 6 ms 1748 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 3 ms 1364 KB Output is correct
38 Correct 4 ms 1364 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 60 ms 8348 KB Output is correct
12 Correct 39 ms 5548 KB Output is correct
13 Correct 40 ms 6784 KB Output is correct
14 Correct 67 ms 8296 KB Output is correct
15 Correct 53 ms 8524 KB Output is correct
16 Correct 33 ms 9356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 60 ms 8348 KB Output is correct
12 Correct 39 ms 5548 KB Output is correct
13 Correct 40 ms 6784 KB Output is correct
14 Correct 67 ms 8296 KB Output is correct
15 Correct 53 ms 8524 KB Output is correct
16 Correct 33 ms 9356 KB Output is correct
17 Correct 0 ms 340 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 2 ms 468 KB Output is correct
22 Correct 89 ms 8804 KB Output is correct
23 Correct 73 ms 8096 KB Output is correct
24 Correct 65 ms 6288 KB Output is correct
25 Correct 79 ms 8492 KB Output is correct
26 Correct 54 ms 8492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 60 ms 8348 KB Output is correct
12 Correct 39 ms 5548 KB Output is correct
13 Correct 40 ms 6784 KB Output is correct
14 Correct 67 ms 8296 KB Output is correct
15 Correct 53 ms 8524 KB Output is correct
16 Correct 33 ms 9356 KB Output is correct
17 Correct 0 ms 340 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 2 ms 468 KB Output is correct
22 Correct 89 ms 8804 KB Output is correct
23 Correct 73 ms 8096 KB Output is correct
24 Correct 65 ms 6288 KB Output is correct
25 Correct 79 ms 8492 KB Output is correct
26 Correct 54 ms 8492 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 1364 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 321 ms 29124 KB Output is correct
35 Correct 225 ms 23564 KB Output is correct
36 Correct 229 ms 21888 KB Output is correct
37 Correct 227 ms 20884 KB Output is correct
38 Correct 64 ms 9020 KB Output is correct
39 Correct 48 ms 14684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 60 ms 8348 KB Output is correct
12 Correct 39 ms 5548 KB Output is correct
13 Correct 40 ms 6784 KB Output is correct
14 Correct 67 ms 8296 KB Output is correct
15 Correct 53 ms 8524 KB Output is correct
16 Correct 33 ms 9356 KB Output is correct
17 Correct 0 ms 340 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 2 ms 468 KB Output is correct
22 Correct 89 ms 8804 KB Output is correct
23 Correct 73 ms 8096 KB Output is correct
24 Correct 65 ms 6288 KB Output is correct
25 Correct 79 ms 8492 KB Output is correct
26 Correct 54 ms 8492 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 1364 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 321 ms 29124 KB Output is correct
35 Correct 225 ms 23564 KB Output is correct
36 Correct 229 ms 21888 KB Output is correct
37 Correct 227 ms 20884 KB Output is correct
38 Correct 64 ms 9020 KB Output is correct
39 Correct 48 ms 14684 KB Output is correct
40 Correct 4 ms 1364 KB Output is correct
41 Correct 5 ms 1748 KB Output is correct
42 Correct 3 ms 1364 KB Output is correct
43 Correct 4 ms 1364 KB Output is correct
44 Correct 431 ms 54656 KB Output is correct
45 Correct 333 ms 41536 KB Output is correct
46 Correct 370 ms 47884 KB Output is correct
47 Correct 335 ms 42472 KB Output is correct
48 Correct 90 ms 11956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 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 468 KB Output is correct
18 Correct 1 ms 468 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 0 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 5 ms 1776 KB Output is correct
27 Correct 5 ms 1748 KB Output is correct
28 Correct 6 ms 1748 KB Output is correct
29 Correct 7 ms 1844 KB Output is correct
30 Correct 4 ms 1364 KB Output is correct
31 Correct 5 ms 1748 KB Output is correct
32 Correct 5 ms 1412 KB Output is correct
33 Correct 3 ms 1108 KB Output is correct
34 Correct 6 ms 1748 KB Output is correct
35 Correct 2 ms 468 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 3 ms 1364 KB Output is correct
38 Correct 4 ms 1364 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
40 Correct 0 ms 340 KB Output is correct
41 Correct 0 ms 340 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 340 KB Output is correct
44 Correct 0 ms 340 KB Output is correct
45 Correct 0 ms 340 KB Output is correct
46 Correct 0 ms 340 KB Output is correct
47 Correct 0 ms 340 KB Output is correct
48 Correct 0 ms 340 KB Output is correct
49 Correct 0 ms 340 KB Output is correct
50 Correct 60 ms 8348 KB Output is correct
51 Correct 39 ms 5548 KB Output is correct
52 Correct 40 ms 6784 KB Output is correct
53 Correct 67 ms 8296 KB Output is correct
54 Correct 53 ms 8524 KB Output is correct
55 Correct 33 ms 9356 KB Output is correct
56 Correct 0 ms 340 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 2 ms 468 KB Output is correct
61 Correct 89 ms 8804 KB Output is correct
62 Correct 73 ms 8096 KB Output is correct
63 Correct 65 ms 6288 KB Output is correct
64 Correct 79 ms 8492 KB Output is correct
65 Correct 54 ms 8492 KB Output is correct
66 Correct 1 ms 468 KB Output is correct
67 Correct 1 ms 468 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 5 ms 1364 KB Output is correct
71 Correct 1 ms 468 KB Output is correct
72 Correct 1 ms 468 KB Output is correct
73 Correct 321 ms 29124 KB Output is correct
74 Correct 225 ms 23564 KB Output is correct
75 Correct 229 ms 21888 KB Output is correct
76 Correct 227 ms 20884 KB Output is correct
77 Correct 64 ms 9020 KB Output is correct
78 Correct 48 ms 14684 KB Output is correct
79 Correct 4 ms 1364 KB Output is correct
80 Correct 5 ms 1748 KB Output is correct
81 Correct 3 ms 1364 KB Output is correct
82 Correct 4 ms 1364 KB Output is correct
83 Correct 431 ms 54656 KB Output is correct
84 Correct 333 ms 41536 KB Output is correct
85 Correct 370 ms 47884 KB Output is correct
86 Correct 335 ms 42472 KB Output is correct
87 Correct 90 ms 11956 KB Output is correct
88 Correct 419 ms 58736 KB Output is correct
89 Correct 450 ms 61352 KB Output is correct
90 Correct 445 ms 59236 KB Output is correct
91 Correct 481 ms 62876 KB Output is correct
92 Correct 431 ms 57116 KB Output is correct
93 Correct 477 ms 62848 KB Output is correct
94 Correct 446 ms 55776 KB Output is correct
95 Correct 221 ms 35072 KB Output is correct
96 Correct 363 ms 58896 KB Output is correct
97 Correct 48 ms 13336 KB Output is correct
98 Correct 142 ms 41048 KB Output is correct
99 Correct 202 ms 41216 KB Output is correct