Submission #968435

# Submission time Handle Problem Language Result Execution time Memory
968435 2024-04-23T12:22:41 Z Vladth11 Team Contest (JOI22_team) C++14
100 / 100
377 ms 52924 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

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) {
            toDel.clear(); /// Normal ca da TLE
            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) {
            toDel.clear(); /// Normal ca da TLE
            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) {
            toDel.clear(); /// Normal ca da TLE
            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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23640 KB Output is correct
2 Correct 5 ms 23640 KB Output is correct
3 Correct 5 ms 23644 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23744 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23772 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23640 KB Output is correct
11 Correct 5 ms 23728 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 6 ms 23644 KB Output is correct
16 Correct 5 ms 23644 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23640 KB Output is correct
19 Correct 5 ms 23648 KB Output is correct
20 Correct 5 ms 23648 KB Output is correct
21 Correct 5 ms 23648 KB Output is correct
22 Correct 6 ms 23648 KB Output is correct
23 Correct 5 ms 23648 KB Output is correct
24 Correct 5 ms 23644 KB Output is correct
25 Correct 7 ms 23644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23640 KB Output is correct
2 Correct 5 ms 23640 KB Output is correct
3 Correct 5 ms 23644 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23744 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23772 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23640 KB Output is correct
11 Correct 5 ms 23728 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 6 ms 23644 KB Output is correct
16 Correct 5 ms 23644 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23640 KB Output is correct
19 Correct 5 ms 23648 KB Output is correct
20 Correct 5 ms 23648 KB Output is correct
21 Correct 5 ms 23648 KB Output is correct
22 Correct 6 ms 23648 KB Output is correct
23 Correct 5 ms 23648 KB Output is correct
24 Correct 5 ms 23644 KB Output is correct
25 Correct 7 ms 23644 KB Output is correct
26 Correct 8 ms 24412 KB Output is correct
27 Correct 9 ms 24412 KB Output is correct
28 Correct 9 ms 24432 KB Output is correct
29 Correct 9 ms 24412 KB Output is correct
30 Correct 8 ms 24156 KB Output is correct
31 Correct 8 ms 24412 KB Output is correct
32 Correct 9 ms 24664 KB Output is correct
33 Correct 9 ms 24412 KB Output is correct
34 Correct 11 ms 24424 KB Output is correct
35 Correct 6 ms 23784 KB Output is correct
36 Correct 6 ms 23908 KB Output is correct
37 Correct 7 ms 24420 KB Output is correct
38 Correct 8 ms 24456 KB Output is correct
39 Correct 6 ms 23912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23652 KB Output is correct
2 Correct 5 ms 23776 KB Output is correct
3 Correct 7 ms 23644 KB Output is correct
4 Correct 5 ms 23696 KB Output is correct
5 Correct 6 ms 23644 KB Output is correct
6 Correct 5 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23640 KB Output is correct
9 Correct 5 ms 23644 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 172 ms 47804 KB Output is correct
12 Correct 149 ms 39876 KB Output is correct
13 Correct 114 ms 43464 KB Output is correct
14 Correct 222 ms 47892 KB Output is correct
15 Correct 176 ms 49352 KB Output is correct
16 Correct 145 ms 49656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23652 KB Output is correct
2 Correct 5 ms 23776 KB Output is correct
3 Correct 7 ms 23644 KB Output is correct
4 Correct 5 ms 23696 KB Output is correct
5 Correct 6 ms 23644 KB Output is correct
6 Correct 5 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23640 KB Output is correct
9 Correct 5 ms 23644 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 172 ms 47804 KB Output is correct
12 Correct 149 ms 39876 KB Output is correct
13 Correct 114 ms 43464 KB Output is correct
14 Correct 222 ms 47892 KB Output is correct
15 Correct 176 ms 49352 KB Output is correct
16 Correct 145 ms 49656 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23644 KB Output is correct
19 Correct 5 ms 23736 KB Output is correct
20 Correct 5 ms 23640 KB Output is correct
21 Correct 7 ms 24044 KB Output is correct
22 Correct 174 ms 47944 KB Output is correct
23 Correct 177 ms 46784 KB Output is correct
24 Correct 170 ms 41056 KB Output is correct
25 Correct 272 ms 47028 KB Output is correct
26 Correct 175 ms 48716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23652 KB Output is correct
2 Correct 5 ms 23776 KB Output is correct
3 Correct 7 ms 23644 KB Output is correct
4 Correct 5 ms 23696 KB Output is correct
5 Correct 6 ms 23644 KB Output is correct
6 Correct 5 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23640 KB Output is correct
9 Correct 5 ms 23644 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 172 ms 47804 KB Output is correct
12 Correct 149 ms 39876 KB Output is correct
13 Correct 114 ms 43464 KB Output is correct
14 Correct 222 ms 47892 KB Output is correct
15 Correct 176 ms 49352 KB Output is correct
16 Correct 145 ms 49656 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23644 KB Output is correct
19 Correct 5 ms 23736 KB Output is correct
20 Correct 5 ms 23640 KB Output is correct
21 Correct 7 ms 24044 KB Output is correct
22 Correct 174 ms 47944 KB Output is correct
23 Correct 177 ms 46784 KB Output is correct
24 Correct 170 ms 41056 KB Output is correct
25 Correct 272 ms 47028 KB Output is correct
26 Correct 175 ms 48716 KB Output is correct
27 Correct 6 ms 23640 KB Output is correct
28 Correct 6 ms 23640 KB Output is correct
29 Correct 5 ms 23644 KB Output is correct
30 Correct 5 ms 23644 KB Output is correct
31 Correct 9 ms 24408 KB Output is correct
32 Correct 6 ms 23896 KB Output is correct
33 Correct 6 ms 23732 KB Output is correct
34 Correct 218 ms 45632 KB Output is correct
35 Correct 237 ms 44576 KB Output is correct
36 Correct 279 ms 48600 KB Output is correct
37 Correct 377 ms 48224 KB Output is correct
38 Correct 188 ms 49404 KB Output is correct
39 Correct 74 ms 38596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23652 KB Output is correct
2 Correct 5 ms 23776 KB Output is correct
3 Correct 7 ms 23644 KB Output is correct
4 Correct 5 ms 23696 KB Output is correct
5 Correct 6 ms 23644 KB Output is correct
6 Correct 5 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23640 KB Output is correct
9 Correct 5 ms 23644 KB Output is correct
10 Correct 5 ms 23644 KB Output is correct
11 Correct 172 ms 47804 KB Output is correct
12 Correct 149 ms 39876 KB Output is correct
13 Correct 114 ms 43464 KB Output is correct
14 Correct 222 ms 47892 KB Output is correct
15 Correct 176 ms 49352 KB Output is correct
16 Correct 145 ms 49656 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23644 KB Output is correct
19 Correct 5 ms 23736 KB Output is correct
20 Correct 5 ms 23640 KB Output is correct
21 Correct 7 ms 24044 KB Output is correct
22 Correct 174 ms 47944 KB Output is correct
23 Correct 177 ms 46784 KB Output is correct
24 Correct 170 ms 41056 KB Output is correct
25 Correct 272 ms 47028 KB Output is correct
26 Correct 175 ms 48716 KB Output is correct
27 Correct 6 ms 23640 KB Output is correct
28 Correct 6 ms 23640 KB Output is correct
29 Correct 5 ms 23644 KB Output is correct
30 Correct 5 ms 23644 KB Output is correct
31 Correct 9 ms 24408 KB Output is correct
32 Correct 6 ms 23896 KB Output is correct
33 Correct 6 ms 23732 KB Output is correct
34 Correct 218 ms 45632 KB Output is correct
35 Correct 237 ms 44576 KB Output is correct
36 Correct 279 ms 48600 KB Output is correct
37 Correct 377 ms 48224 KB Output is correct
38 Correct 188 ms 49404 KB Output is correct
39 Correct 74 ms 38596 KB Output is correct
40 Correct 7 ms 24156 KB Output is correct
41 Correct 8 ms 24408 KB Output is correct
42 Correct 7 ms 24412 KB Output is correct
43 Correct 8 ms 24412 KB Output is correct
44 Correct 235 ms 48588 KB Output is correct
45 Correct 293 ms 48820 KB Output is correct
46 Correct 278 ms 48808 KB Output is correct
47 Correct 292 ms 48816 KB Output is correct
48 Correct 200 ms 50388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 23640 KB Output is correct
2 Correct 5 ms 23640 KB Output is correct
3 Correct 5 ms 23644 KB Output is correct
4 Correct 5 ms 23644 KB Output is correct
5 Correct 5 ms 23744 KB Output is correct
6 Correct 6 ms 23644 KB Output is correct
7 Correct 5 ms 23644 KB Output is correct
8 Correct 5 ms 23772 KB Output is correct
9 Correct 5 ms 23640 KB Output is correct
10 Correct 5 ms 23640 KB Output is correct
11 Correct 5 ms 23728 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 6 ms 23644 KB Output is correct
16 Correct 5 ms 23644 KB Output is correct
17 Correct 6 ms 23644 KB Output is correct
18 Correct 5 ms 23640 KB Output is correct
19 Correct 5 ms 23648 KB Output is correct
20 Correct 5 ms 23648 KB Output is correct
21 Correct 5 ms 23648 KB Output is correct
22 Correct 6 ms 23648 KB Output is correct
23 Correct 5 ms 23648 KB Output is correct
24 Correct 5 ms 23644 KB Output is correct
25 Correct 7 ms 23644 KB Output is correct
26 Correct 8 ms 24412 KB Output is correct
27 Correct 9 ms 24412 KB Output is correct
28 Correct 9 ms 24432 KB Output is correct
29 Correct 9 ms 24412 KB Output is correct
30 Correct 8 ms 24156 KB Output is correct
31 Correct 8 ms 24412 KB Output is correct
32 Correct 9 ms 24664 KB Output is correct
33 Correct 9 ms 24412 KB Output is correct
34 Correct 11 ms 24424 KB Output is correct
35 Correct 6 ms 23784 KB Output is correct
36 Correct 6 ms 23908 KB Output is correct
37 Correct 7 ms 24420 KB Output is correct
38 Correct 8 ms 24456 KB Output is correct
39 Correct 6 ms 23912 KB Output is correct
40 Correct 5 ms 23652 KB Output is correct
41 Correct 5 ms 23776 KB Output is correct
42 Correct 7 ms 23644 KB Output is correct
43 Correct 5 ms 23696 KB Output is correct
44 Correct 6 ms 23644 KB Output is correct
45 Correct 5 ms 23644 KB Output is correct
46 Correct 5 ms 23644 KB Output is correct
47 Correct 5 ms 23640 KB Output is correct
48 Correct 5 ms 23644 KB Output is correct
49 Correct 5 ms 23644 KB Output is correct
50 Correct 172 ms 47804 KB Output is correct
51 Correct 149 ms 39876 KB Output is correct
52 Correct 114 ms 43464 KB Output is correct
53 Correct 222 ms 47892 KB Output is correct
54 Correct 176 ms 49352 KB Output is correct
55 Correct 145 ms 49656 KB Output is correct
56 Correct 6 ms 23644 KB Output is correct
57 Correct 5 ms 23644 KB Output is correct
58 Correct 5 ms 23736 KB Output is correct
59 Correct 5 ms 23640 KB Output is correct
60 Correct 7 ms 24044 KB Output is correct
61 Correct 174 ms 47944 KB Output is correct
62 Correct 177 ms 46784 KB Output is correct
63 Correct 170 ms 41056 KB Output is correct
64 Correct 272 ms 47028 KB Output is correct
65 Correct 175 ms 48716 KB Output is correct
66 Correct 6 ms 23640 KB Output is correct
67 Correct 6 ms 23640 KB Output is correct
68 Correct 5 ms 23644 KB Output is correct
69 Correct 5 ms 23644 KB Output is correct
70 Correct 9 ms 24408 KB Output is correct
71 Correct 6 ms 23896 KB Output is correct
72 Correct 6 ms 23732 KB Output is correct
73 Correct 218 ms 45632 KB Output is correct
74 Correct 237 ms 44576 KB Output is correct
75 Correct 279 ms 48600 KB Output is correct
76 Correct 377 ms 48224 KB Output is correct
77 Correct 188 ms 49404 KB Output is correct
78 Correct 74 ms 38596 KB Output is correct
79 Correct 7 ms 24156 KB Output is correct
80 Correct 8 ms 24408 KB Output is correct
81 Correct 7 ms 24412 KB Output is correct
82 Correct 8 ms 24412 KB Output is correct
83 Correct 235 ms 48588 KB Output is correct
84 Correct 293 ms 48820 KB Output is correct
85 Correct 278 ms 48808 KB Output is correct
86 Correct 292 ms 48816 KB Output is correct
87 Correct 200 ms 50388 KB Output is correct
88 Correct 227 ms 50356 KB Output is correct
89 Correct 274 ms 50616 KB Output is correct
90 Correct 263 ms 50620 KB Output is correct
91 Correct 271 ms 50540 KB Output is correct
92 Correct 260 ms 49216 KB Output is correct
93 Correct 261 ms 49404 KB Output is correct
94 Correct 305 ms 49304 KB Output is correct
95 Correct 202 ms 52152 KB Output is correct
96 Correct 233 ms 50756 KB Output is correct
97 Correct 158 ms 52924 KB Output is correct
98 Correct 88 ms 49072 KB Output is correct
99 Correct 122 ms 49220 KB Output is correct