Submission #987052

#TimeUsernameProblemLanguageResultExecution timeMemory
987052aaaaaarrozTeam Contest (JOI22_team)C++17
100 / 100
389 ms27316 KiB
#include<bits/stdc++.h> #define f first #define s second #define pb push_back #define pii pair<int,int> #define ll long long #define sz(x) (ll)x.size() using namespace std; int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n;cin>>n; int x[n+1],y[n+1],z[n+1];multiset<pii>xx,yy,zz; for(int i=1;i<=n;i++)cin>>x[i]>>y[i]>>z[i],xx.insert({x[i],i}),yy.insert({y[i],i}),zz.insert({z[i],i}); while(!xx.empty()){ int a=(--xx.end())->s,b=(--yy.end())->s,c=(--zz.end())->s; if(y[a]==y[b]){xx.erase({x[a],a}),yy.erase({y[a],a}),zz.erase({z[a],a});continue;} else if(z[a]==z[c]){xx.erase({x[a],a}),yy.erase({y[a],a}),zz.erase({z[a],a});continue;} else if(x[b]==x[a]){xx.erase({x[b],b}),yy.erase({y[b],b}),zz.erase({z[b],b});continue;} else if(z[b]==z[c]){xx.erase({x[b],b}),yy.erase({y[b],b}),zz.erase({z[b],b});continue;} else if(x[c]==x[a]){xx.erase({x[c],c}),yy.erase({y[c],c}),zz.erase({z[c],c});continue;} else if(y[c]==y[b]){xx.erase({x[c],c}),yy.erase({y[c],c}),zz.erase({z[c],c});continue;} else break; }if(xx.empty())cout<<-1; else cout<<(--xx.end())->f+(--yy.end())->f+(--zz.end())->f; 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...