제출 #892437

#제출 시각아이디문제언어결과실행 시간메모리
892437vjudge1Team Contest (JOI22_team)C++17
100 / 100
388 ms34388 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define mpa make_pair #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define bc back() #define ar array #define vll vector<ll> using namespace std;/* #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds;*/ template <class _T> bool chmin(_T &x, const _T &y){ if(x>y){ x=y; return true; } return false; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag=false; if (x<y){ x=y;flag|=true; } return flag; } //#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=2e18+7; const ll mod=1e9+7; const ll N=2e5+7; const ld eps=1e-9; void solve(){ ll i; ll n,k; cin>>n; ll xx[n],yy[n],zz[n]; set<pair<ll,ll>> x,y,z; for(i=0;i<n;i++){ ll a,b,c; cin>>a>>b>>c; xx[i]=a; yy[i]=b; zz[i]=c; x.ins({a,i}); y.ins({b,i}); z.ins({c,i}); } for(i=0;i<n;i++){ vector<ll> v; v.pb(x.rbegin()->sc); v.pb(y.rbegin()->sc); v.pb(z.rbegin()->sc); if(yy[v[1]]==yy[v[0]] || zz[v[0]]==zz[v[2]]){ x.erase(x.find({xx[v[0]],v[0]})); y.erase(y.find({yy[v[0]],v[0]})); z.erase(z.find({zz[v[0]],v[0]})); }else if(xx[v[1]]==xx[v[0]] || zz[v[1]]==zz[v[2]]){ x.erase(x.find({xx[v[1]],v[1]})); y.erase(y.find({yy[v[1]],v[1]})); z.erase(z.find({zz[v[1]],v[1]})); }else if(xx[v[2]]==xx[v[0]] || yy[v[1]]==yy[v[2]]){ x.erase(x.find({xx[v[2]],v[2]})); y.erase(y.find({yy[v[2]],v[2]})); z.erase(z.find({zz[v[2]],v[2]})); }else{ cout<<xx[v[0]]+yy[v[1]]+zz[v[2]]<<endl; return; } } cout<<-1<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

team.cpp: In function 'void solve()':
team.cpp:56:7: warning: unused variable 'k' [-Wunused-variable]
   56 |  ll n,k;
      |       ^
team.cpp: In function 'void fre(std::string)':
team.cpp:43:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:43:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...