답안 #1096876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096876 2024-10-05T10:20:21 Z thangdz2k7 Team Contest (JOI22_team) C++17
100 / 100
109 ms 12512 KB
// author : thembululquaUwU
// 3.9.2024

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define endl '\n'

using namespace std;
using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using ar = array <int, 4>;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

void maxl(auto &a, auto b) {a = max(a, b);}
void minl(auto &a, auto b) {a = min(a, b);}

vector <ar> V[3];
bool bad[N];
int n;

#define fr(i) for (int i = 0; i < 3; ++ i)
#define V(x, y) V[x][i[x]][y]

void solve(){
    cin >> n; int i[] = {n - 1, n - 1, n - 1};
    for (int j = 0; j < n; ++ j){
        int x, y, z; cin >> x >> y >> z;
        fr(t) V[t].pb({x, y, z, j});
    }
    fr(t) sort(V[t].begin(), V[t].end(), [&](ar a, ar b) {return a[t] < b[t]; });
    while (true){
        fr(j) {
            while (i[j] >= 0 && bad[(V(j, 3))]) -- i[j];
            if (i[j] < 0){
                cout << -1;
                return;
            }
        }
        ll ans = 0;
        vi v; fr(j) v.pb(V(j, 3)), ans += V(j, j); bool ok = 0;
        fr(j) fr(t) if ((j ^ t) && V(j, j) == V(t, j)) bad[v[t]] = 1, ok = 1;
        if (!ok) {
            cout << ans << endl; return;
        }
    }
}

int main(){
    if (fopen("pqh.inp", "r")){
        freopen("pqh.inp", "r", stdin);
        freopen("pqh.out", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1; // cin >> t;
    while (t --) solve();
    return 0;
}

Compilation message

team.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
team.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
team.cpp:20:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
team.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   20 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
team.cpp: In function 'int main()':
team.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   55 |         freopen("pqh.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
team.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         freopen("pqh.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 400 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 468 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 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 400 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 4 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 728 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 4 ms 604 KB Output is correct
39 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 9656 KB Output is correct
12 Correct 39 ms 5812 KB Output is correct
13 Correct 35 ms 7092 KB Output is correct
14 Correct 59 ms 9652 KB Output is correct
15 Correct 49 ms 9656 KB Output is correct
16 Correct 53 ms 9644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 9656 KB Output is correct
12 Correct 39 ms 5812 KB Output is correct
13 Correct 35 ms 7092 KB Output is correct
14 Correct 59 ms 9652 KB Output is correct
15 Correct 49 ms 9656 KB Output is correct
16 Correct 53 ms 9644 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 59 ms 9908 KB Output is correct
23 Correct 53 ms 9656 KB Output is correct
24 Correct 44 ms 6564 KB Output is correct
25 Correct 66 ms 9908 KB Output is correct
26 Correct 53 ms 9656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 9656 KB Output is correct
12 Correct 39 ms 5812 KB Output is correct
13 Correct 35 ms 7092 KB Output is correct
14 Correct 59 ms 9652 KB Output is correct
15 Correct 49 ms 9656 KB Output is correct
16 Correct 53 ms 9644 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 59 ms 9908 KB Output is correct
23 Correct 53 ms 9656 KB Output is correct
24 Correct 44 ms 6564 KB Output is correct
25 Correct 66 ms 9908 KB Output is correct
26 Correct 53 ms 9656 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 65 ms 10360 KB Output is correct
35 Correct 66 ms 10136 KB Output is correct
36 Correct 73 ms 10264 KB Output is correct
37 Correct 76 ms 10424 KB Output is correct
38 Correct 57 ms 10156 KB Output is correct
39 Correct 30 ms 5816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 47 ms 9656 KB Output is correct
12 Correct 39 ms 5812 KB Output is correct
13 Correct 35 ms 7092 KB Output is correct
14 Correct 59 ms 9652 KB Output is correct
15 Correct 49 ms 9656 KB Output is correct
16 Correct 53 ms 9644 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 59 ms 9908 KB Output is correct
23 Correct 53 ms 9656 KB Output is correct
24 Correct 44 ms 6564 KB Output is correct
25 Correct 66 ms 9908 KB Output is correct
26 Correct 53 ms 9656 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 65 ms 10360 KB Output is correct
35 Correct 66 ms 10136 KB Output is correct
36 Correct 73 ms 10264 KB Output is correct
37 Correct 76 ms 10424 KB Output is correct
38 Correct 57 ms 10156 KB Output is correct
39 Correct 30 ms 5816 KB Output is correct
40 Correct 2 ms 728 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 1 ms 780 KB Output is correct
43 Correct 3 ms 600 KB Output is correct
44 Correct 86 ms 10668 KB Output is correct
45 Correct 86 ms 10672 KB Output is correct
46 Correct 84 ms 10660 KB Output is correct
47 Correct 89 ms 10688 KB Output is correct
48 Correct 60 ms 10680 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 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 400 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 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 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 468 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 3 ms 604 KB Output is correct
27 Correct 2 ms 600 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 4 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 3 ms 604 KB Output is correct
32 Correct 2 ms 604 KB Output is correct
33 Correct 2 ms 728 KB Output is correct
34 Correct 3 ms 604 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 4 ms 604 KB Output is correct
39 Correct 1 ms 600 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 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 0 ms 456 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 47 ms 9656 KB Output is correct
51 Correct 39 ms 5812 KB Output is correct
52 Correct 35 ms 7092 KB Output is correct
53 Correct 59 ms 9652 KB Output is correct
54 Correct 49 ms 9656 KB Output is correct
55 Correct 53 ms 9644 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 1 ms 604 KB Output is correct
61 Correct 59 ms 9908 KB Output is correct
62 Correct 53 ms 9656 KB Output is correct
63 Correct 44 ms 6564 KB Output is correct
64 Correct 66 ms 9908 KB Output is correct
65 Correct 53 ms 9656 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 2 ms 604 KB Output is correct
71 Correct 1 ms 348 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 65 ms 10360 KB Output is correct
74 Correct 66 ms 10136 KB Output is correct
75 Correct 73 ms 10264 KB Output is correct
76 Correct 76 ms 10424 KB Output is correct
77 Correct 57 ms 10156 KB Output is correct
78 Correct 30 ms 5816 KB Output is correct
79 Correct 2 ms 728 KB Output is correct
80 Correct 2 ms 604 KB Output is correct
81 Correct 1 ms 780 KB Output is correct
82 Correct 3 ms 600 KB Output is correct
83 Correct 86 ms 10668 KB Output is correct
84 Correct 86 ms 10672 KB Output is correct
85 Correct 84 ms 10660 KB Output is correct
86 Correct 89 ms 10688 KB Output is correct
87 Correct 60 ms 10680 KB Output is correct
88 Correct 90 ms 12512 KB Output is correct
89 Correct 100 ms 12284 KB Output is correct
90 Correct 100 ms 12196 KB Output is correct
91 Correct 105 ms 12212 KB Output is correct
92 Correct 86 ms 10924 KB Output is correct
93 Correct 98 ms 11444 KB Output is correct
94 Correct 97 ms 11176 KB Output is correct
95 Correct 69 ms 12196 KB Output is correct
96 Correct 103 ms 12216 KB Output is correct
97 Correct 65 ms 12460 KB Output is correct
98 Correct 45 ms 11176 KB Output is correct
99 Correct 109 ms 11084 KB Output is correct