이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> x(n), y(n), z(n); 
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i] >> z[i];
  }
  vector<int> ptx(n), pty(n), ptz(n);
  iota(ptx.begin(), ptx.end(), 0);
  iota(pty.begin(), pty.end(), 0);
  iota(ptz.begin(), ptz.end(), 0);
  sort(ptx.begin(), ptx.end(), [&](int i, int j) {
    return x[i] < x[j];
  });
  sort(pty.begin(), pty.end(), [&](int i, int j) {
    return y[i] < y[j];
  });
  sort(ptz.begin(), ptz.end(), [&](int i, int j) {
    return z[i] < z[j];
  });
  int tx = n - 1, ty = n - 1, tz = n - 1;
  vector<bool> used(n); 
  while (tx >= 0 && ty >= 0 && tz >= 0) {
    int mx = x[ptx[tx]], my = y[pty[ty]], mz = z[ptz[tz]];
    int cntx = 1 + (y[ptx[tx]] == my) + (z[ptx[tx]] == mz);
    int cnty = 1 + (x[pty[ty]] == mx) + (z[pty[ty]] == mz);
    int cntz = 1 + (x[ptz[tz]] == mx) + (y[ptz[tz]] == mz);
    if (cntx >= 2) {
      used[ptx[tx]] = true;
      tx--; 
    } else if (cnty >= 2) {
      used[pty[ty]] = true;
      ty--;
    } else if (cntz >= 2) {
      used[ptz[tz]] = true;
      tz--;
    } else {
      cout << (long long) mx + my + mz << '\n';
      return 0; 
    }
    while (tx >= 0 && used[ptx[tx]]) tx--;
    while (ty >= 0 && used[pty[ty]]) ty--;
    while (tz >= 0 && used[ptz[tz]]) tz--;
  }
  cout << -1 << '\n';
  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... |