Submission #892437

# Submission time Handle Problem Language Result Execution time Memory
892437 2023-12-25T10:43:18 Z vjudge1 Team Contest (JOI22_team) C++17
100 / 100
388 ms 34388 KB
#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;
}

Compilation message

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 time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 4 ms 1372 KB Output is correct
27 Correct 4 ms 1372 KB Output is correct
28 Correct 4 ms 1372 KB Output is correct
29 Correct 5 ms 1368 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 5 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 4 ms 1404 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 3 ms 1116 KB Output is correct
39 Correct 1 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 164 ms 32668 KB Output is correct
12 Correct 117 ms 21844 KB Output is correct
13 Correct 114 ms 26960 KB Output is correct
14 Correct 188 ms 32848 KB Output is correct
15 Correct 140 ms 32848 KB Output is correct
16 Correct 140 ms 32848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 164 ms 32668 KB Output is correct
12 Correct 117 ms 21844 KB Output is correct
13 Correct 114 ms 26960 KB Output is correct
14 Correct 188 ms 32848 KB Output is correct
15 Correct 140 ms 32848 KB Output is correct
16 Correct 140 ms 32848 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 168 ms 32852 KB Output is correct
23 Correct 180 ms 32080 KB Output is correct
24 Correct 177 ms 24144 KB Output is correct
25 Correct 259 ms 32832 KB Output is correct
26 Correct 149 ms 32808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 164 ms 32668 KB Output is correct
12 Correct 117 ms 21844 KB Output is correct
13 Correct 114 ms 26960 KB Output is correct
14 Correct 188 ms 32848 KB Output is correct
15 Correct 140 ms 32848 KB Output is correct
16 Correct 140 ms 32848 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 168 ms 32852 KB Output is correct
23 Correct 180 ms 32080 KB Output is correct
24 Correct 177 ms 24144 KB Output is correct
25 Correct 259 ms 32832 KB Output is correct
26 Correct 149 ms 32808 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 5 ms 1232 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 271 ms 31632 KB Output is correct
35 Correct 271 ms 30148 KB Output is correct
36 Correct 312 ms 33148 KB Output is correct
37 Correct 335 ms 32852 KB Output is correct
38 Correct 190 ms 32436 KB Output is correct
39 Correct 92 ms 20140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 164 ms 32668 KB Output is correct
12 Correct 117 ms 21844 KB Output is correct
13 Correct 114 ms 26960 KB Output is correct
14 Correct 188 ms 32848 KB Output is correct
15 Correct 140 ms 32848 KB Output is correct
16 Correct 140 ms 32848 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 168 ms 32852 KB Output is correct
23 Correct 180 ms 32080 KB Output is correct
24 Correct 177 ms 24144 KB Output is correct
25 Correct 259 ms 32832 KB Output is correct
26 Correct 149 ms 32808 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 5 ms 1232 KB Output is correct
32 Correct 1 ms 604 KB Output is correct
33 Correct 1 ms 604 KB Output is correct
34 Correct 271 ms 31632 KB Output is correct
35 Correct 271 ms 30148 KB Output is correct
36 Correct 312 ms 33148 KB Output is correct
37 Correct 335 ms 32852 KB Output is correct
38 Correct 190 ms 32436 KB Output is correct
39 Correct 92 ms 20140 KB Output is correct
40 Correct 3 ms 856 KB Output is correct
41 Correct 3 ms 1116 KB Output is correct
42 Correct 3 ms 1308 KB Output is correct
43 Correct 3 ms 1116 KB Output is correct
44 Correct 283 ms 33176 KB Output is correct
45 Correct 375 ms 33344 KB Output is correct
46 Correct 383 ms 33268 KB Output is correct
47 Correct 371 ms 33368 KB Output is correct
48 Correct 218 ms 33212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 456 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 600 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 4 ms 1372 KB Output is correct
27 Correct 4 ms 1372 KB Output is correct
28 Correct 4 ms 1372 KB Output is correct
29 Correct 5 ms 1368 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 1116 KB Output is correct
32 Correct 5 ms 1116 KB Output is correct
33 Correct 4 ms 1116 KB Output is correct
34 Correct 4 ms 1404 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 1 ms 604 KB Output is correct
37 Correct 2 ms 1116 KB Output is correct
38 Correct 3 ms 1116 KB Output is correct
39 Correct 1 ms 860 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 452 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 460 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 344 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 164 ms 32668 KB Output is correct
51 Correct 117 ms 21844 KB Output is correct
52 Correct 114 ms 26960 KB Output is correct
53 Correct 188 ms 32848 KB Output is correct
54 Correct 140 ms 32848 KB Output is correct
55 Correct 140 ms 32848 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 1 ms 860 KB Output is correct
61 Correct 168 ms 32852 KB Output is correct
62 Correct 180 ms 32080 KB Output is correct
63 Correct 177 ms 24144 KB Output is correct
64 Correct 259 ms 32832 KB Output is correct
65 Correct 149 ms 32808 KB Output is correct
66 Correct 0 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 364 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 5 ms 1232 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 1 ms 604 KB Output is correct
73 Correct 271 ms 31632 KB Output is correct
74 Correct 271 ms 30148 KB Output is correct
75 Correct 312 ms 33148 KB Output is correct
76 Correct 335 ms 32852 KB Output is correct
77 Correct 190 ms 32436 KB Output is correct
78 Correct 92 ms 20140 KB Output is correct
79 Correct 3 ms 856 KB Output is correct
80 Correct 3 ms 1116 KB Output is correct
81 Correct 3 ms 1308 KB Output is correct
82 Correct 3 ms 1116 KB Output is correct
83 Correct 283 ms 33176 KB Output is correct
84 Correct 375 ms 33344 KB Output is correct
85 Correct 383 ms 33268 KB Output is correct
86 Correct 371 ms 33368 KB Output is correct
87 Correct 218 ms 33212 KB Output is correct
88 Correct 297 ms 34104 KB Output is correct
89 Correct 330 ms 34388 KB Output is correct
90 Correct 292 ms 34172 KB Output is correct
91 Correct 358 ms 34128 KB Output is correct
92 Correct 322 ms 33616 KB Output is correct
93 Correct 350 ms 33664 KB Output is correct
94 Correct 388 ms 33616 KB Output is correct
95 Correct 230 ms 34128 KB Output is correct
96 Correct 183 ms 34136 KB Output is correct
97 Correct 156 ms 34132 KB Output is correct
98 Correct 149 ms 33432 KB Output is correct
99 Correct 158 ms 33636 KB Output is correct