Submission #850506

#TimeUsernameProblemLanguageResultExecution timeMemory
850506EJIC_B_KEDAXTeam Contest (JOI22_team)C++14
0 / 100
2036 ms348 KiB
#include <bits/stdc++.h> #include <random> #ifndef LOCAL // #pragma GCC optimize("O3") // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") // #pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt") #endif using namespace std; typedef long long ll; typedef double dd; typedef long double ld; typedef unsigned int uii; #define x first #define y second #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() void solve(); mt19937_64 mt(1); int32_t main() { #ifdef LOCAL freopen("input.in", "r", stdin); freopen("output.out", "w", stdout); #else ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); //freopen("amusing.in", "r", stdin); //freopen("amusing.out", "w", stdout); #endif cout << fixed << setprecision(30); int tests = 1; //cin >> tests; while (tests--) { solve(); } } void solve() { int n; cin >> n; set<pair<int, int>> xs, ys, zs; vector<int> x(n), y(n), z(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> z[i]; xs.emplace(-x[i], i); ys.emplace(-y[i], i); zs.emplace(-z[i], i); } while (!x.empty()) { pair<int, int> f = *xs.begin(), s = *ys.begin(), t = *zs.begin(); int i = f.y, j = s.y, l = t.y; if (i == j) { xs.erase({-x[i], i}); ys.erase({-y[i], i}); zs.erase({-z[i], i}); continue; } if (i == l) { xs.erase({-x[i], i}); ys.erase({-y[i], i}); zs.erase({-z[i], i}); continue; } if (l == j) { xs.erase({-x[j], j}); ys.erase({-y[j], j}); zs.erase({-z[j], j}); continue; } cout << -(f.x + t.x + s.x) << '\n'; return; } 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...