Submission #1189544

#TimeUsernameProblemLanguageResultExecution timeMemory
1189544mannshah1211Team Contest (JOI22_team)C++20
0 / 100
50 ms6316 KiB
/** * author: tourist * created: 21.04.2025 16:49:29 **/ #include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #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<pair<int, int>> sx, sy, sz; for (int i = 0; i < n; i++) { sx.emplace_back(x[i], i); sy.emplace_back(y[i], i); sz.emplace_back(z[i], i); } sort(sx.begin(), sx.end()); sort(sy.begin(), sy.end()); sort(sz.begin(), sz.end()); int ptr_x = n - 1, ptr_y = n - 1, ptr_z = n - 1; vector<bool> vis(n); while (ptr_x >= 0 && ptr_y >= 0 && ptr_z >= 0) { while (ptr_x >= 0 && vis[sx[ptr_x].second]) { ptr_x -= 1; } while (ptr_y >= 0 && vis[sy[ptr_y].second]) { ptr_y -= 1; } if (ptr_z >= 0 && vis[sz[ptr_z].second]) { ptr_z -= 1; } if (ptr_x < 0 || ptr_y < 0 || ptr_z < 0) { break; } int id_x = sx[ptr_x].second, id_y = sy[ptr_y].second, id_z = sz[ptr_z].second, vx = sx[ptr_x].first, vy = sy[ptr_y].first, vz = sz[ptr_z].first; if (vx == x[id_y]) { vis[id_y] = true; continue; } if (vx == x[id_z]) { vis[id_z] = true; continue; } if (vy == y[id_z]) { vis[id_z] = true; continue; } if (vy == y[id_x]) { vis[id_x] = true; continue; } if (vz == z[id_x]) { vis[id_x] = true; continue; } if (vz == z[id_y]) { vis[id_y] = true; continue; } cout << sx[ptr_x].first + sy[ptr_y].first + sz[ptr_z].first << '\n'; return 0; } cout << -1 << '\n'; return 0; }
#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...