이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
int n;
vector<pair<int,ii> > v;
set<ii> x,y,z;
int main(){
scanf("%d",&n);
int X,Y,Z;
for(int i=0;i<n;i++){
scanf("%d%d%d",&X,&Y,&Z);
v.pb(X,mp(Y,Z));
}
sort(ALL(v));
v.resize(unique(ALL(v))-v.begin());
n=SZ(v);
for(int i=0;i<n;i++){
x.insert(mp(v[i].fi,i));
y.insert(mp(v[i].se.fi,i));
z.insert(mp(v[i].se.se,i));
}
x.insert(mp(-1,-1));
y.insert(mp(-1,-1));
z.insert(mp(-1,-1));
for(int i=0;i<n;i++){
auto itx=--x.end(),ity=--y.end(),itz=--z.end();
ii a=(*itx),b=(*ity),c=(*itz);
if(a.se!=b.se&&b.se!=c.se&&c.se!=a.se){
printf("%d",a.fi+b.fi+c.fi);
return 0;
}
if(a.se==b.se&&b.se==c.se){
x.erase(itx);
y.erase(ity);
z.erase(itz);
}else if(a.se==b.se){
x.erase(itx);
y.erase(ity);
z.erase(mp(v[a.se].se.se,a.se));
}else if(b.se==c.se){
x.erase(mp(v[b.se].fi,b.se));
y.erase(ity);
z.erase(itz);
}else{
x.erase(itx);
y.erase(mp(v[a.se].se.fi,a.se));
z.erase(itz);
}
}
printf("-1");
}
컴파일 시 표준 에러 (stderr) 메시지
team.cpp: In function 'int main()':
team.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
24 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
team.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | scanf("%d%d%d",&X,&Y,&Z);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |