답안 #1059585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059585 2024-08-15T05:44:29 Z vjudge1 Team Contest (JOI22_team) C++17
100 / 100
375 ms 36048 KB
#include <bits/stdc++.h>

using namespace std;
    
typedef long long ll;
#define int ll
const int  N = 2e5 + 2, MOD = 998244353;

int a[N],b[N],c[N],n;
set<pair<int,int>> x,y,z;
void del(int i) {
    x.erase({a[i],i});
    y.erase({b[i],i});
    z.erase({c[i],i});
}
void test() {
    cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i] >> b[i] >> c[i];
        x.insert({a[i],i});
        y.insert({b[i],i});
        z.insert({c[i],i});
    }
    while(true) {
        if(x.empty()) {
            cout << -1;
            return;
        }
        auto [v,i] = (*x.rbegin());
        auto [v1,j] = (*y.rbegin());
        auto [v2,k] = (*z.rbegin());
        auto bad = [&](int id)->bool{
            int col = 0;
            if(a[id] == (*x.rbegin()).first) col++;
            if(b[id] == (*y.rbegin()).first) col++;
            if(c[id] == (*z.rbegin()).first) col++;
            if(col > 1) return 1;
            return 0;
        };
        if(i == j && j == k) {
            del(i);
            continue;
        }
        if(i == j || i == k) {
            del(i);
            continue;
        } else if(j == k) {
            del(j);
            continue;
        }
        bool ok = 1;
        if(bad(i)) {
            ok = false;
            del(i);
        }
        if(bad(j)) {
            ok = false;
            del(j);
        }
        if(bad(k)) {
            ok = false;
            del(k);
        }
        if(ok) {
            cout << v + v1 + v2;
            return;
        }
    }
}
signed main() {
    ios_base::sync_with_stdio(false);cin.tie(0);
    int t = 1; 
    // cin >> t;
    while(t--) {
        test();
    }
}  
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 480 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 460 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 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 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 0 ms 348 KB Output is correct
25 Correct 1 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 480 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 460 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 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 3 ms 1372 KB Output is correct
27 Correct 3 ms 1372 KB Output is correct
28 Correct 4 ms 1372 KB Output is correct
29 Correct 4 ms 1372 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 3 ms 1372 KB Output is correct
34 Correct 3 ms 1372 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 3 ms 1372 KB Output is correct
39 Correct 1 ms 860 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 356 KB Output is correct
5 Correct 0 ms 352 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 133 ms 33036 KB Output is correct
12 Correct 99 ms 22100 KB Output is correct
13 Correct 83 ms 27216 KB Output is correct
14 Correct 178 ms 33104 KB Output is correct
15 Correct 127 ms 33008 KB Output is correct
16 Correct 128 ms 32876 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 356 KB Output is correct
5 Correct 0 ms 352 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 133 ms 33036 KB Output is correct
12 Correct 99 ms 22100 KB Output is correct
13 Correct 83 ms 27216 KB Output is correct
14 Correct 178 ms 33104 KB Output is correct
15 Correct 127 ms 33008 KB Output is correct
16 Correct 128 ms 32876 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 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 860 KB Output is correct
22 Correct 144 ms 33280 KB Output is correct
23 Correct 154 ms 32084 KB Output is correct
24 Correct 133 ms 23996 KB Output is correct
25 Correct 243 ms 33152 KB Output is correct
26 Correct 144 ms 33060 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 356 KB Output is correct
5 Correct 0 ms 352 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 133 ms 33036 KB Output is correct
12 Correct 99 ms 22100 KB Output is correct
13 Correct 83 ms 27216 KB Output is correct
14 Correct 178 ms 33104 KB Output is correct
15 Correct 127 ms 33008 KB Output is correct
16 Correct 128 ms 32876 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 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 860 KB Output is correct
22 Correct 144 ms 33280 KB Output is correct
23 Correct 154 ms 32084 KB Output is correct
24 Correct 133 ms 23996 KB Output is correct
25 Correct 243 ms 33152 KB Output is correct
26 Correct 144 ms 33060 KB Output is correct
27 Correct 0 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 1 ms 348 KB Output is correct
31 Correct 4 ms 1372 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 252 ms 32144 KB Output is correct
35 Correct 249 ms 30548 KB Output is correct
36 Correct 293 ms 33616 KB Output is correct
37 Correct 321 ms 33408 KB Output is correct
38 Correct 189 ms 32848 KB Output is correct
39 Correct 88 ms 20304 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 356 KB Output is correct
5 Correct 0 ms 352 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 352 KB Output is correct
8 Correct 0 ms 352 KB Output is correct
9 Correct 0 ms 360 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 133 ms 33036 KB Output is correct
12 Correct 99 ms 22100 KB Output is correct
13 Correct 83 ms 27216 KB Output is correct
14 Correct 178 ms 33104 KB Output is correct
15 Correct 127 ms 33008 KB Output is correct
16 Correct 128 ms 32876 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 0 ms 344 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 860 KB Output is correct
22 Correct 144 ms 33280 KB Output is correct
23 Correct 154 ms 32084 KB Output is correct
24 Correct 133 ms 23996 KB Output is correct
25 Correct 243 ms 33152 KB Output is correct
26 Correct 144 ms 33060 KB Output is correct
27 Correct 0 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 1 ms 348 KB Output is correct
31 Correct 4 ms 1372 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 252 ms 32144 KB Output is correct
35 Correct 249 ms 30548 KB Output is correct
36 Correct 293 ms 33616 KB Output is correct
37 Correct 321 ms 33408 KB Output is correct
38 Correct 189 ms 32848 KB Output is correct
39 Correct 88 ms 20304 KB Output is correct
40 Correct 2 ms 860 KB Output is correct
41 Correct 3 ms 1372 KB Output is correct
42 Correct 2 ms 1352 KB Output is correct
43 Correct 3 ms 1368 KB Output is correct
44 Correct 277 ms 34072 KB Output is correct
45 Correct 364 ms 34056 KB Output is correct
46 Correct 328 ms 33996 KB Output is correct
47 Correct 357 ms 34104 KB Output is correct
48 Correct 226 ms 34124 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 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 480 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 460 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 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 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 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 3 ms 1372 KB Output is correct
27 Correct 3 ms 1372 KB Output is correct
28 Correct 4 ms 1372 KB Output is correct
29 Correct 4 ms 1372 KB Output is correct
30 Correct 3 ms 856 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 3 ms 1372 KB Output is correct
34 Correct 3 ms 1372 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 3 ms 1372 KB Output is correct
39 Correct 1 ms 860 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 356 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 1 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 360 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 133 ms 33036 KB Output is correct
51 Correct 99 ms 22100 KB Output is correct
52 Correct 83 ms 27216 KB Output is correct
53 Correct 178 ms 33104 KB Output is correct
54 Correct 127 ms 33008 KB Output is correct
55 Correct 128 ms 32876 KB Output is correct
56 Correct 0 ms 344 KB Output is correct
57 Correct 0 ms 344 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 860 KB Output is correct
61 Correct 144 ms 33280 KB Output is correct
62 Correct 154 ms 32084 KB Output is correct
63 Correct 133 ms 23996 KB Output is correct
64 Correct 243 ms 33152 KB Output is correct
65 Correct 144 ms 33060 KB Output is correct
66 Correct 0 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 1 ms 348 KB Output is correct
70 Correct 4 ms 1372 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 252 ms 32144 KB Output is correct
74 Correct 249 ms 30548 KB Output is correct
75 Correct 293 ms 33616 KB Output is correct
76 Correct 321 ms 33408 KB Output is correct
77 Correct 189 ms 32848 KB Output is correct
78 Correct 88 ms 20304 KB Output is correct
79 Correct 2 ms 860 KB Output is correct
80 Correct 3 ms 1372 KB Output is correct
81 Correct 2 ms 1352 KB Output is correct
82 Correct 3 ms 1368 KB Output is correct
83 Correct 277 ms 34072 KB Output is correct
84 Correct 364 ms 34056 KB Output is correct
85 Correct 328 ms 33996 KB Output is correct
86 Correct 357 ms 34104 KB Output is correct
87 Correct 226 ms 34124 KB Output is correct
88 Correct 281 ms 35940 KB Output is correct
89 Correct 346 ms 35920 KB Output is correct
90 Correct 293 ms 36048 KB Output is correct
91 Correct 342 ms 35964 KB Output is correct
92 Correct 323 ms 34404 KB Output is correct
93 Correct 325 ms 34880 KB Output is correct
94 Correct 375 ms 34568 KB Output is correct
95 Correct 200 ms 35920 KB Output is correct
96 Correct 159 ms 35920 KB Output is correct
97 Correct 149 ms 35924 KB Output is correct
98 Correct 135 ms 34644 KB Output is correct
99 Correct 139 ms 34460 KB Output is correct