답안 #968432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968432 2024-04-23T12:21:28 Z Vladth11 Team Contest (JOI22_team) C++14
55 / 100
2000 ms 49740 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
 
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
 
const ll NMAX = 150005;
const ll INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
 
set <int> x[NMAX];
vector <int> nx;
set <int> y[NMAX];
vector <int> ny;
set <int> z[NMAX];
vector <int> nz;
 
int xx[NMAX], yy[NMAX], zz[NMAX];
 
void nrm(vector <int> &x) {
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
}
 
int f[NMAX];
 
void sterge(set <int> &s, int x){
    if(s.find(x) != s.end())
    s.erase(x);
}
 
void totalDelete(int acum) {
    sterge(x[xx[acum]], acum);
    sterge(y[yy[acum]], acum);
    sterge(z[zz[acum]], acum);
}
 
signed main() {
#ifdef HOME
    ifstream cin(".in");
    ofstream cout(".out");
#endif // HOME
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i, n;
    cin >> n;
    for(i = 1; i <= n; i++) {
        cin >> xx[i] >> yy[i] >> zz[i];
        nx.push_back(xx[i]);
        ny.push_back(yy[i]);
        nz.push_back(zz[i]);
    }
    nrm(nx);
    nrm(ny);
    nrm(nz);
    for(i = 1; i <= n; i++) {
        xx[i] = lower_bound(nx.begin(), nx.end(), xx[i]) - nx.begin() + 1;
        yy[i] = lower_bound(ny.begin(), ny.end(), yy[i]) - ny.begin() + 1;
        zz[i] = lower_bound(nz.begin(), nz.end(), zz[i]) - nz.begin() + 1;
        x[xx[i]].insert(i);
        y[yy[i]].insert(i);
        z[zz[i]].insert(i);
    }
    int indx = nx.size(), indy = ny.size(), indz = nz.size();
    vector <int> toDel;
    for(auto acum : x[indx]) {
        f[acum]++;
        if(f[acum] > 1) {
            toDel.push_back(acum);
        }
    }
    for(auto acum : y[indy]) {
        f[acum]++;
        if(f[acum] > 1) {
            toDel.push_back(acum);
        }
    }
    for(auto acum : z[indz]) {
        f[acum]++;
        if(f[acum] > 1) {
            toDel.push_back(acum);
        }
    }
    for(auto acum : toDel) {
        totalDelete(acum);
    }
    int oke = 1;
    while(oke && indx > 0 && indy > 0 && indz > 0) {
        oke = 0;
        while(indx > 0 && x[indx].size() == 0) {
            indx--;
            oke = 1;
            for(auto acum : x[indx]) {
                f[acum]++;
                if(f[acum] > 1) {
                    toDel.push_back(acum);
                }
            }
            for(auto acum : toDel) {
                totalDelete(acum);
            }
        }
        while(indy > 0 && y[indy].size() == 0) {
            indy--;
            oke = 1;
            for(auto acum : y[indy]) {
                f[acum]++;
                if(f[acum] > 1) {
                    toDel.push_back(acum);
                }
            }
            for(auto acum : toDel) {
                totalDelete(acum);
            }
        }
        while(indz > 0 && z[indz].size() == 0) {
            indz--;
            oke = 1;
            for(auto acum : z[indz]) {
                f[acum]++;
                if(f[acum] > 1) {
                    toDel.push_back(acum);
                }
            }
            for(auto acum : toDel) {
                totalDelete(acum);
            }
        }
    }
    if(indx > 0 && indy > 0 && indz > 0) {
        cout << nx[indx - 1] + ny[indy - 1] + nz[indz - 1];
    } else {
        cout << "-1";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 23640 KB Output is correct
2 Correct 6 ms 23728 KB Output is correct
3 Correct 5 ms 23640 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23724 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 6 ms 23644 KB Output is correct
8 Correct 7 ms 23644 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 5 ms 23772 KB Output is correct
12 Correct 5 ms 23644 KB Output is correct
13 Correct 5 ms 23644 KB Output is correct
14 Correct 6 ms 23644 KB Output is correct
15 Correct 5 ms 23644 KB Output is correct
16 Correct 5 ms 23640 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 6 ms 23644 KB Output is correct
19 Correct 5 ms 23644 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 6 ms 23644 KB Output is correct
22 Correct 6 ms 23644 KB Output is correct
23 Correct 6 ms 23644 KB Output is correct
24 Correct 6 ms 23640 KB Output is correct
25 Correct 5 ms 23640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 23640 KB Output is correct
2 Correct 6 ms 23728 KB Output is correct
3 Correct 5 ms 23640 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23724 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 6 ms 23644 KB Output is correct
8 Correct 7 ms 23644 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 5 ms 23772 KB Output is correct
12 Correct 5 ms 23644 KB Output is correct
13 Correct 5 ms 23644 KB Output is correct
14 Correct 6 ms 23644 KB Output is correct
15 Correct 5 ms 23644 KB Output is correct
16 Correct 5 ms 23640 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 6 ms 23644 KB Output is correct
19 Correct 5 ms 23644 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 6 ms 23644 KB Output is correct
22 Correct 6 ms 23644 KB Output is correct
23 Correct 6 ms 23644 KB Output is correct
24 Correct 6 ms 23640 KB Output is correct
25 Correct 5 ms 23640 KB Output is correct
26 Correct 9 ms 24156 KB Output is correct
27 Correct 13 ms 24412 KB Output is correct
28 Correct 31 ms 24412 KB Output is correct
29 Correct 138 ms 24416 KB Output is correct
30 Correct 32 ms 24156 KB Output is correct
31 Correct 12 ms 24412 KB Output is correct
32 Correct 41 ms 24432 KB Output is correct
33 Correct 88 ms 24424 KB Output is correct
34 Correct 156 ms 24432 KB Output is correct
35 Correct 6 ms 23908 KB Output is correct
36 Correct 10 ms 23912 KB Output is correct
37 Correct 7 ms 24168 KB Output is correct
38 Correct 53 ms 24396 KB Output is correct
39 Correct 7 ms 23912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 23656 KB Output is correct
2 Correct 5 ms 23656 KB Output is correct
3 Correct 6 ms 23656 KB Output is correct
4 Correct 5 ms 23656 KB Output is correct
5 Correct 8 ms 23744 KB Output is correct
6 Correct 6 ms 23656 KB Output is correct
7 Correct 5 ms 23760 KB Output is correct
8 Correct 5 ms 23768 KB Output is correct
9 Correct 5 ms 23656 KB Output is correct
10 Correct 5 ms 23656 KB Output is correct
11 Correct 176 ms 46900 KB Output is correct
12 Correct 206 ms 39840 KB Output is correct
13 Correct 129 ms 42692 KB Output is correct
14 Correct 336 ms 48204 KB Output is correct
15 Correct 219 ms 48376 KB Output is correct
16 Correct 152 ms 49740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 23656 KB Output is correct
2 Correct 5 ms 23656 KB Output is correct
3 Correct 6 ms 23656 KB Output is correct
4 Correct 5 ms 23656 KB Output is correct
5 Correct 8 ms 23744 KB Output is correct
6 Correct 6 ms 23656 KB Output is correct
7 Correct 5 ms 23760 KB Output is correct
8 Correct 5 ms 23768 KB Output is correct
9 Correct 5 ms 23656 KB Output is correct
10 Correct 5 ms 23656 KB Output is correct
11 Correct 176 ms 46900 KB Output is correct
12 Correct 206 ms 39840 KB Output is correct
13 Correct 129 ms 42692 KB Output is correct
14 Correct 336 ms 48204 KB Output is correct
15 Correct 219 ms 48376 KB Output is correct
16 Correct 152 ms 49740 KB Output is correct
17 Correct 6 ms 23652 KB Output is correct
18 Correct 6 ms 23652 KB Output is correct
19 Correct 5 ms 23652 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 8 ms 23900 KB Output is correct
22 Correct 191 ms 47572 KB Output is correct
23 Correct 292 ms 47248 KB Output is correct
24 Correct 457 ms 42004 KB Output is correct
25 Correct 719 ms 49160 KB Output is correct
26 Correct 195 ms 49264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 23656 KB Output is correct
2 Correct 5 ms 23656 KB Output is correct
3 Correct 6 ms 23656 KB Output is correct
4 Correct 5 ms 23656 KB Output is correct
5 Correct 8 ms 23744 KB Output is correct
6 Correct 6 ms 23656 KB Output is correct
7 Correct 5 ms 23760 KB Output is correct
8 Correct 5 ms 23768 KB Output is correct
9 Correct 5 ms 23656 KB Output is correct
10 Correct 5 ms 23656 KB Output is correct
11 Correct 176 ms 46900 KB Output is correct
12 Correct 206 ms 39840 KB Output is correct
13 Correct 129 ms 42692 KB Output is correct
14 Correct 336 ms 48204 KB Output is correct
15 Correct 219 ms 48376 KB Output is correct
16 Correct 152 ms 49740 KB Output is correct
17 Correct 6 ms 23652 KB Output is correct
18 Correct 6 ms 23652 KB Output is correct
19 Correct 5 ms 23652 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 8 ms 23900 KB Output is correct
22 Correct 191 ms 47572 KB Output is correct
23 Correct 292 ms 47248 KB Output is correct
24 Correct 457 ms 42004 KB Output is correct
25 Correct 719 ms 49160 KB Output is correct
26 Correct 195 ms 49264 KB Output is correct
27 Correct 6 ms 23652 KB Output is correct
28 Correct 6 ms 23644 KB Output is correct
29 Correct 7 ms 23640 KB Output is correct
30 Correct 7 ms 23644 KB Output is correct
31 Correct 38 ms 24492 KB Output is correct
32 Correct 5 ms 23900 KB Output is correct
33 Correct 8 ms 23932 KB Output is correct
34 Correct 227 ms 47028 KB Output is correct
35 Execution timed out 2054 ms 46564 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 23656 KB Output is correct
2 Correct 5 ms 23656 KB Output is correct
3 Correct 6 ms 23656 KB Output is correct
4 Correct 5 ms 23656 KB Output is correct
5 Correct 8 ms 23744 KB Output is correct
6 Correct 6 ms 23656 KB Output is correct
7 Correct 5 ms 23760 KB Output is correct
8 Correct 5 ms 23768 KB Output is correct
9 Correct 5 ms 23656 KB Output is correct
10 Correct 5 ms 23656 KB Output is correct
11 Correct 176 ms 46900 KB Output is correct
12 Correct 206 ms 39840 KB Output is correct
13 Correct 129 ms 42692 KB Output is correct
14 Correct 336 ms 48204 KB Output is correct
15 Correct 219 ms 48376 KB Output is correct
16 Correct 152 ms 49740 KB Output is correct
17 Correct 6 ms 23652 KB Output is correct
18 Correct 6 ms 23652 KB Output is correct
19 Correct 5 ms 23652 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 8 ms 23900 KB Output is correct
22 Correct 191 ms 47572 KB Output is correct
23 Correct 292 ms 47248 KB Output is correct
24 Correct 457 ms 42004 KB Output is correct
25 Correct 719 ms 49160 KB Output is correct
26 Correct 195 ms 49264 KB Output is correct
27 Correct 6 ms 23652 KB Output is correct
28 Correct 6 ms 23644 KB Output is correct
29 Correct 7 ms 23640 KB Output is correct
30 Correct 7 ms 23644 KB Output is correct
31 Correct 38 ms 24492 KB Output is correct
32 Correct 5 ms 23900 KB Output is correct
33 Correct 8 ms 23932 KB Output is correct
34 Correct 227 ms 47028 KB Output is correct
35 Execution timed out 2054 ms 46564 KB Time limit exceeded
36 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 23640 KB Output is correct
2 Correct 6 ms 23728 KB Output is correct
3 Correct 5 ms 23640 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23724 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 6 ms 23644 KB Output is correct
8 Correct 7 ms 23644 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 5 ms 23772 KB Output is correct
12 Correct 5 ms 23644 KB Output is correct
13 Correct 5 ms 23644 KB Output is correct
14 Correct 6 ms 23644 KB Output is correct
15 Correct 5 ms 23644 KB Output is correct
16 Correct 5 ms 23640 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 6 ms 23644 KB Output is correct
19 Correct 5 ms 23644 KB Output is correct
20 Correct 5 ms 23644 KB Output is correct
21 Correct 6 ms 23644 KB Output is correct
22 Correct 6 ms 23644 KB Output is correct
23 Correct 6 ms 23644 KB Output is correct
24 Correct 6 ms 23640 KB Output is correct
25 Correct 5 ms 23640 KB Output is correct
26 Correct 9 ms 24156 KB Output is correct
27 Correct 13 ms 24412 KB Output is correct
28 Correct 31 ms 24412 KB Output is correct
29 Correct 138 ms 24416 KB Output is correct
30 Correct 32 ms 24156 KB Output is correct
31 Correct 12 ms 24412 KB Output is correct
32 Correct 41 ms 24432 KB Output is correct
33 Correct 88 ms 24424 KB Output is correct
34 Correct 156 ms 24432 KB Output is correct
35 Correct 6 ms 23908 KB Output is correct
36 Correct 10 ms 23912 KB Output is correct
37 Correct 7 ms 24168 KB Output is correct
38 Correct 53 ms 24396 KB Output is correct
39 Correct 7 ms 23912 KB Output is correct
40 Correct 5 ms 23656 KB Output is correct
41 Correct 5 ms 23656 KB Output is correct
42 Correct 6 ms 23656 KB Output is correct
43 Correct 5 ms 23656 KB Output is correct
44 Correct 8 ms 23744 KB Output is correct
45 Correct 6 ms 23656 KB Output is correct
46 Correct 5 ms 23760 KB Output is correct
47 Correct 5 ms 23768 KB Output is correct
48 Correct 5 ms 23656 KB Output is correct
49 Correct 5 ms 23656 KB Output is correct
50 Correct 176 ms 46900 KB Output is correct
51 Correct 206 ms 39840 KB Output is correct
52 Correct 129 ms 42692 KB Output is correct
53 Correct 336 ms 48204 KB Output is correct
54 Correct 219 ms 48376 KB Output is correct
55 Correct 152 ms 49740 KB Output is correct
56 Correct 6 ms 23652 KB Output is correct
57 Correct 6 ms 23652 KB Output is correct
58 Correct 5 ms 23652 KB Output is correct
59 Correct 5 ms 23644 KB Output is correct
60 Correct 8 ms 23900 KB Output is correct
61 Correct 191 ms 47572 KB Output is correct
62 Correct 292 ms 47248 KB Output is correct
63 Correct 457 ms 42004 KB Output is correct
64 Correct 719 ms 49160 KB Output is correct
65 Correct 195 ms 49264 KB Output is correct
66 Correct 6 ms 23652 KB Output is correct
67 Correct 6 ms 23644 KB Output is correct
68 Correct 7 ms 23640 KB Output is correct
69 Correct 7 ms 23644 KB Output is correct
70 Correct 38 ms 24492 KB Output is correct
71 Correct 5 ms 23900 KB Output is correct
72 Correct 8 ms 23932 KB Output is correct
73 Correct 227 ms 47028 KB Output is correct
74 Execution timed out 2054 ms 46564 KB Time limit exceeded
75 Halted 0 ms 0 KB -