Submission #673612

#TimeUsernameProblemLanguageResultExecution timeMemory
673612peijarTeam Contest (JOI22_team)C++17
100 / 100
115 ms11384 KiB
#include <bits/stdc++.h> #include <ostream> #define int long long using namespace std; struct Contestant { int x, y, z; }; signed main(void) { ios_base::sync_with_stdio(false); cin.tie(0); int N; cin >> N; vector<Contestant> contestants(N); for (auto &[x, y, z] : contestants) cin >> x >> y >> z; vector<int> ordX(N), ordY(N), ordZ(N); for (int i = 0; i < N; ++i) ordX[i] = ordY[i] = ordZ[i] = i; sort(ordX.begin(), ordX.end(), [&](int i, int j) { return pair(contestants[i].x, i) < pair(contestants[j].x, j); }); sort(ordY.begin(), ordY.end(), [&](int i, int j) { return pair(contestants[i].y, i) < pair(contestants[j].y, j); }); sort(ordZ.begin(), ordZ.end(), [&](int i, int j) { return pair(contestants[i].z, i) < pair(contestants[j].z, j); }); int posX = N - 1, posY = N - 1, posZ = N - 1; vector<bool> erased(N); while (posX >= 0 and posY >= 0 and posZ >= 0) { int ix = ordX[posX], iy = ordY[posY], iz = ordZ[posZ]; int X = contestants[ordX[posX]].x, Y = contestants[ordY[posY]].y, Z = contestants[ordZ[posZ]].z; if (Y == contestants[ix].y or Z == contestants[ix].z) erased[ix] = true; else if (X == contestants[iy].x or Z == contestants[iy].z) erased[iy] = true; else if (X == contestants[iz].x or Y == contestants[iz].y) erased[iz] = true; else { cout << X + Y + Z << endl; return 0; } while (posX >= 0 and erased[ordX[posX]]) --posX; while (posY >= 0 and erased[ordY[posY]]) --posY; while (posZ >= 0 and erased[ordZ[posZ]]) --posZ; } cout << -1 << endl; }
#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...