Submission #794954

#TimeUsernameProblemLanguageResultExecution timeMemory
794954vjudge1Team Contest (JOI22_team)C++17
100 / 100
77 ms7916 KiB
#include <bits/stdc++.h> #define fi first #define se second const int N = 200200; const int mod = 1e9 + 7; using namespace std; int n; bool used[N]; int x[N], y[N], z[N]; int main() { #ifdef zxc freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin >> n; vector<int> a(n), b(n), c(n); for (int i = 1; i <= n; i++) { cin >> x[i] >> y[i] >> z[i]; a[i - 1] = i; b[i - 1] = i; c[i - 1] = i; } sort(a.begin(), a.end(), [&](int i, int j){return x[i] > x[j]; }); sort(b.begin(), b.end(), [&](int i, int j){return y[i] > y[j]; }); sort(c.begin(), c.end(), [&](int i, int j){return z[i] > z[j]; }); int i = 0, j = 0, h = 0; while (i < n && j < n && h < n) { if (used[a[i]]) { i++; } else if (used[b[j]]) { j++; } else if (used[c[h]]) { h++; } else if (y[a[i]] == y[b[j]] || z[a[i]] == z[c[h]]) { used[a[i++]] = true; } else if (x[b[j]] == x[a[i]] || z[b[j]] == z[c[h]]) { used[b[j++]] = true; } else if (x[c[h]] == x[a[i]] || y[c[h]] == y[b[j]]) { used[c[h++]] = true; } else { cout << x[a[i]] + y[b[j]] + z[c[h]] << "\n"; return 0; } } cout << -1 << "\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...