이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<stdio.h>
#include<stdint.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
#include<map>
#include<queue>
#include<stack>
using namespace std;
const int64_t INF = (int64_t) 1e18 + 777;
const int64_t mINF = 2500 + 5;
const int64_t MOD = 1e9 + 9;
const int nbit = 11;
const int ndig = 10;
const int nchar = 26;
const int p1 = 31;
const int p2 = 53;
const int D = 4;
int dr[D] = {0, 1, 0, -1};
int dc[D] = {1, 0, -1, 0};
struct Thing
{
    int x;
    int y;
    int z;
    Thing(int x_, int y_, int z_) : x(x_), y(y_), z(z_) {}
};
struct Solution
{
    Solution() {}
    void solve()
    {
        int n;
        cin >> n;
        vector<Thing> v(n, Thing(-1, -1, -1));
        set<pair<int, int> > a;
        set<pair<int, int> > b;
        set<pair<int, int> > c;
        for(int i = 0; i < n; i++)
        {
            cin >> v[i].x >> v[i].y >> v[i].z;
            a.insert(make_pair(-v[i].x, i));
            b.insert(make_pair(-v[i].y, i));
            c.insert(make_pair(-v[i].z, i));
        }
        int ans = -1;
        for(int t = 0; t < n; t++)
        {
            int i = a.begin()->second;
            int j = b.begin()->second;
            int k = c.begin()->second;
            int max_x = v[i].x;
            int max_y = v[j].y;
            int max_z = v[k].z;
            if(v[i].y == max_y || v[i].z == max_z)
            {
                a.erase(make_pair(-v[i].x, i));
                b.erase(make_pair(-v[i].y, i));
                c.erase(make_pair(-v[i].z, i));
                continue;
            }
            if(v[j].x == max_x || v[j].z == max_z)
            {
                a.erase(make_pair(-v[j].x, j));
                b.erase(make_pair(-v[j].y, j));
                c.erase(make_pair(-v[j].z, j));
                continue;
            }
            if(v[k].x == max_x || v[k].y == max_y)
            {
                a.erase(make_pair(-v[k].x, k));
                b.erase(make_pair(-v[k].y, k));
                c.erase(make_pair(-v[k].z, k));
                continue;
            }
            ans = v[i].x + v[j].y + v[k].z;
            break;
        }
        cout << ans << "\n";
    }
    int modsub(int t1, int t2)
    {
        int res = t1 - t2;
        if(res < 0) res += MOD;
        return res;
    }
    int modadd(int t1, int t2)
    {
        int res = t1 + t2;
        if(res >= MOD) res -= MOD;
        return res;
    }
    int modmul(int t1, int t2)
    {
        int64_t res = 1LL * t1 * t2;
        return (res % MOD);
    }
    bool BIT(int& mask, int& j)
    {
        return (mask & MASK(j));
    }
    int MASK(int j)
    {
        return (1 << j);
    }
};
void __startup()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
}
int main()
{
    __startup();
    int t = 1;
//    cin >> t;
    for(int i = 1; i <= t; i++)
    {
        Solution().solve();
    }
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |