제출 #1184333

#제출 시각아이디문제언어결과실행 시간메모리
1184333GrayTeam Contest (JOI22_team)C++20
0 / 100
46 ms2696 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define ff first #define ss second #define ln "\n" #define mp make_pair #define pb push_back #define INF (ll)2e18 #define MOD (ll)(1e9+7) void solve(){ ll n; cin >> n; map<ll, vector<pair<ll, ll>>> a; for (ll i=0; i<n; i++){ ll x, y, z; cin >> x >> y >> z; a[x].push_back({y, z}); } set<pair<ll, ll>> yz, zy; ll res=-1; for (auto &[x, ar]:a){ if (yz.size()>=2){ for (auto [y, z]:ar){ pair<ll, ll> yzt = *yz.rbegin(); pair<ll, ll> zyt = *zy.rbegin(); pair<ll, ll> yzpt, zypt; yzpt=zypt={-1, -1}; auto iter1 = yz.upper_bound({yzt.ff-1, INF}); auto iter2 = zy.upper_bound({zyt.ff-1, INF}); if (iter1!=yz.begin()){ iter1--; yzpt = *iter1; } if (iter2!=zy.begin()){ iter2--; zypt = *iter2; } swap(zyt.ff, zyt.ss); swap(zypt.ff, zypt.ss); vector<pair<ll, ll>> cur = {zyt, yzt, zypt, yzpt}; if (iter1!=yz.begin()){ iter1--; yzpt = *iter1; cur.push_back(yzpt); } if (iter2!=zy.begin()){ iter2--; zypt = *iter2; swap(zypt.ff, zypt.ss); cur.push_back(zypt); } if (iter1!=yz.begin()){ iter1--; yzpt = *iter1; cur.push_back(yzpt); } if (iter2!=zy.begin()){ iter2--; zypt = *iter2; swap(zypt.ff, zypt.ss); cur.push_back(zypt); } yzpt = *prev(prev(yz.end())); cur.push_back(yzpt); zypt = *prev(prev(zy.end())); cur.push_back({zypt.ss, zypt.ff}); if (yz.size()>2){ yzpt = *prev(prev(prev(yz.end()))); cur.push_back(yzpt); zypt = *prev(prev(prev(zy.end()))); cur.push_back({zypt.ss, zypt.ff}); } for (ll i=0; i<(ll)cur.size(); i++){ // if (x==5){ // cout << cur[i].ff << " " << cur[i].ss << ln; // } for (ll j=i+1; j<(ll)cur.size(); j++){ if (cur[i].ff!=-1 and cur[j].ff!=-1){ if (cur[i].ff>cur[j].ff and cur[i].ss<cur[j].ss and cur[i].ff>y and cur[j].ss>z){ res=max(res, cur[i].ff+cur[j].ss+x); }else if (cur[i].ff<cur[j].ff and cur[i].ss>cur[j].ss and cur[i].ss>z and cur[j].ff>y){ res=max(res, x+cur[i].ss+cur[j].ff); } } } } } } for (auto [y, z]:ar){ yz.insert({y, z}); zy.insert({z, y}); } } cout << res << ln; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifdef LOCAL auto start = chrono::high_resolution_clock::now(); #endif ll t=1; // cin >> t; for (ll c=1; c<=t; c++) solve(); #ifdef LOCAL auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start); cout << setprecision(0) << fixed << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl; #endif }
#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...