Submission #544573

#TimeUsernameProblemLanguageResultExecution timeMemory
544573Rafi22Team Contest (JOI22_team)C++14
100 / 100
128 ms6128 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define st first #define nd second #define pb push_back #define sz(x) (int)(x).size() #define all(x) (x).begin(), (x).end() #define ll long long ll mod=1000000007; int inf=1000000007; ll infl=1000000000000000007; const int N=150007; int x[N],y[N],z[N]; bool del[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; priority_queue<pair<int,int>>Qx,Qy,Qz; for(int i=1;i<=n;i++) { cin>>x[i]>>y[i]>>z[i]; Qx.push({x[i],i}); Qy.push({y[i],i}); Qz.push({z[i],i}); } while(true) { while(sz(Qx)>0&&del[Qx.top().nd]) Qx.pop(); while(sz(Qy)>0&&del[Qy.top().nd]) Qy.pop(); while(sz(Qz)>0&&del[Qz.top().nd]) Qz.pop(); if(sz(Qx)==0||sz(Qy)==0||sz(Qz)==0) break; int i=Qx.top().nd; // cout<<"i: "<<i<<endl; if(y[i]==Qy.top().st||z[i]==Qz.top().st) { del[i]=1; continue; } int j=Qy.top().nd; // cout<<"j: "<<j<<endl; if(x[j]==Qx.top().st||z[j]==Qz.top().st) { del[j]=1; continue; } int k=Qz.top().nd; // cout<<"k: "<<k<<endl; if(x[k]==Qx.top().st||y[k]==Qy.top().st) { del[k]=1; continue; } cout<<x[i]+y[j]+z[k]; 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...