제출 #1136539

#제출 시각아이디문제언어결과실행 시간메모리
1136539mariaclaraTeam Contest (JOI22_team)C++20
0 / 100
22 ms328 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> trio;
const int MAXN = 5e5+5;
const ll MOD = 1e9+7;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define X get<0>
#define Y get<1>
#define Z get<2>

int n;
set<trio> x, y, z;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for(int i = 1, a, b, c; i <= n; i++) {
        cin >> a >> b >> c;
        x.insert({a,b,c});
        y.insert({b,c,a});
        z.insert({c,a,b});
    }

    int ans = -1;

    while(!x.empty()) {
        trio mx = *x.rbegin(), my = *y.rbegin(), mz = *z.rbegin();

        if(Y(mx) == X(my) or Z(mx) == X(mz)) {
            x.erase({X(mx), Y(mx), Z(mx)});
            y.erase({Y(mx), Z(mx), X(mx)});
            z.erase({Z(mx), X(mx), Y(mx)});
            continue;
        }

        if(Y(my) ==X(mz)) {
            y.erase({X(my), Y(my), Z(my)});
            z.erase({Y(my), Z(my), X(my)});
            x.erase({Z(my), X(my), Y(my)});
            continue;
        }

        ans = X(mx) + X(my) + X(mz);
        break;
    }

    cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...