Submission #1279058

#TimeUsernameProblemLanguageResultExecution timeMemory
1279058janson0109Team Contest (JOI22_team)C++20
100 / 100
350 ms36824 KiB
#include <bits/stdc++.h> #define F first #define S second #define lol ios::sync_with_stdio(false);cin.tie(NULL); typedef long long ll; typedef long double ld; using namespace std; const ll M = 998244353; int main() { lol ll n; cin >> n; vector<vector<ll>> xyz(n, vector<ll>(3)); for(ll i=0; i<n; i++) for(ll j=0; j<3; j++) cin >> xyz[i][j]; vector<set<pair<ll,ll>, greater<pair<ll,ll>>>> a(3); for(ll i=0; i<n; i++) for(ll j=0; j<3; j++) a[j].insert({xyz[i][j], i}); while(!a[0].empty()) { bool works = 1; for(ll i=0; i<3; i++) { if(!works) break; for(ll j=0; j<3; j++) if(j!=i && xyz[a[j].begin()->S][i] == a[i].begin()->F) { works = 0; ll t = a[j].begin() -> S; for(ll k=0; k<3; k++) a[k].erase({xyz[t][k], t}); break; } } if(works) { cout << (a[0].begin()->F + a[1].begin()->F + a[2].begin()->F); return 0; } } cout << "-1"; 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...