Submission #567755

# Submission time Handle Problem Language Result Execution time Memory
567755 2022-05-24T06:58:43 Z jamielim Team Contest (JOI22_team) C++14
100 / 100
414 ms 23336 KB
#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;

void rem(int idx){
	x.erase(mp(v[idx].fi,idx));
	y.erase(mp(v[idx].se.fi,idx));
	z.erase(mp(v[idx].se.se,idx));
}

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){
			rem(a.se);
		}else if(a.se==b.se){
			rem(a.se);
		}else if(b.se==c.se){
			rem(b.se);
		}else if(a.se==c.se){
			rem(a.se);
		}else{
			bool A=(a.fi>v[b.se].fi&&a.fi>v[c.se].fi);
			bool B=(b.fi>v[a.se].se.fi&&b.fi>v[c.se].se.fi);
			bool C=(c.fi>v[a.se].se.se&&c.fi>v[b.se].se.se);
			if(A&&B&&C){
				printf("%d",a.fi+b.fi+c.fi);
				return 0;
			}else if(!A){ // a.fi==v[b.se].fi or a.fi==v[c.se].fi
				if(a.fi==v[b.se].fi){
					rem(b.se);
				}else{
					rem(c.se);
				}
			}else if(!B){ // b.fi==v[a.se].se.fi or b.fi==v[c.se].se.fi
				if(b.fi==v[a.se].se.fi){
					rem(a.se);
				}else{
					rem(c.se);
				}
			}else{ // !C --> c.fi==v[a.se].se.se or c.fi==v[b.se].se.se
				if(c.fi==v[a.se].se.se){
					rem(a.se);
				}else{
					rem(b.se);
				}
			}
		}
	}
	printf("-1");
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:30:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
team.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d%d%d",&X,&Y,&Z);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 268 KB Output is correct
26 Correct 4 ms 852 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 5 ms 852 KB Output is correct
29 Correct 8 ms 828 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 5 ms 852 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 4 ms 852 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 4 ms 852 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 39 ms 3400 KB Output is correct
12 Correct 24 ms 1940 KB Output is correct
13 Correct 31 ms 1868 KB Output is correct
14 Correct 38 ms 3420 KB Output is correct
15 Correct 35 ms 3436 KB Output is correct
16 Correct 31 ms 3400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 39 ms 3400 KB Output is correct
12 Correct 24 ms 1940 KB Output is correct
13 Correct 31 ms 1868 KB Output is correct
14 Correct 38 ms 3420 KB Output is correct
15 Correct 35 ms 3436 KB Output is correct
16 Correct 31 ms 3400 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 54 ms 3460 KB Output is correct
23 Correct 41 ms 3400 KB Output is correct
24 Correct 31 ms 1884 KB Output is correct
25 Correct 45 ms 3440 KB Output is correct
26 Correct 35 ms 3416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 39 ms 3400 KB Output is correct
12 Correct 24 ms 1940 KB Output is correct
13 Correct 31 ms 1868 KB Output is correct
14 Correct 38 ms 3420 KB Output is correct
15 Correct 35 ms 3436 KB Output is correct
16 Correct 31 ms 3400 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 54 ms 3460 KB Output is correct
23 Correct 41 ms 3400 KB Output is correct
24 Correct 31 ms 1884 KB Output is correct
25 Correct 45 ms 3440 KB Output is correct
26 Correct 35 ms 3416 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 195 ms 22012 KB Output is correct
35 Correct 200 ms 19540 KB Output is correct
36 Correct 221 ms 21560 KB Output is correct
37 Correct 157 ms 15488 KB Output is correct
38 Correct 39 ms 3424 KB Output is correct
39 Correct 99 ms 13984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 39 ms 3400 KB Output is correct
12 Correct 24 ms 1940 KB Output is correct
13 Correct 31 ms 1868 KB Output is correct
14 Correct 38 ms 3420 KB Output is correct
15 Correct 35 ms 3436 KB Output is correct
16 Correct 31 ms 3400 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 54 ms 3460 KB Output is correct
23 Correct 41 ms 3400 KB Output is correct
24 Correct 31 ms 1884 KB Output is correct
25 Correct 45 ms 3440 KB Output is correct
26 Correct 35 ms 3416 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 195 ms 22012 KB Output is correct
35 Correct 200 ms 19540 KB Output is correct
36 Correct 221 ms 21560 KB Output is correct
37 Correct 157 ms 15488 KB Output is correct
38 Correct 39 ms 3424 KB Output is correct
39 Correct 99 ms 13984 KB Output is correct
40 Correct 3 ms 596 KB Output is correct
41 Correct 4 ms 852 KB Output is correct
42 Correct 3 ms 852 KB Output is correct
43 Correct 4 ms 852 KB Output is correct
44 Correct 279 ms 23104 KB Output is correct
45 Correct 414 ms 23080 KB Output is correct
46 Correct 324 ms 23264 KB Output is correct
47 Correct 366 ms 23008 KB Output is correct
48 Correct 47 ms 3400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 268 KB Output is correct
26 Correct 4 ms 852 KB Output is correct
27 Correct 4 ms 852 KB Output is correct
28 Correct 5 ms 852 KB Output is correct
29 Correct 8 ms 828 KB Output is correct
30 Correct 3 ms 596 KB Output is correct
31 Correct 5 ms 852 KB Output is correct
32 Correct 5 ms 852 KB Output is correct
33 Correct 4 ms 724 KB Output is correct
34 Correct 4 ms 852 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 3 ms 852 KB Output is correct
38 Correct 4 ms 852 KB Output is correct
39 Correct 2 ms 468 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 39 ms 3400 KB Output is correct
51 Correct 24 ms 1940 KB Output is correct
52 Correct 31 ms 1868 KB Output is correct
53 Correct 38 ms 3420 KB Output is correct
54 Correct 35 ms 3436 KB Output is correct
55 Correct 31 ms 3400 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 2 ms 468 KB Output is correct
61 Correct 54 ms 3460 KB Output is correct
62 Correct 41 ms 3400 KB Output is correct
63 Correct 31 ms 1884 KB Output is correct
64 Correct 45 ms 3440 KB Output is correct
65 Correct 35 ms 3416 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 340 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 5 ms 852 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 2 ms 340 KB Output is correct
73 Correct 195 ms 22012 KB Output is correct
74 Correct 200 ms 19540 KB Output is correct
75 Correct 221 ms 21560 KB Output is correct
76 Correct 157 ms 15488 KB Output is correct
77 Correct 39 ms 3424 KB Output is correct
78 Correct 99 ms 13984 KB Output is correct
79 Correct 3 ms 596 KB Output is correct
80 Correct 4 ms 852 KB Output is correct
81 Correct 3 ms 852 KB Output is correct
82 Correct 4 ms 852 KB Output is correct
83 Correct 279 ms 23104 KB Output is correct
84 Correct 414 ms 23080 KB Output is correct
85 Correct 324 ms 23264 KB Output is correct
86 Correct 366 ms 23008 KB Output is correct
87 Correct 47 ms 3400 KB Output is correct
88 Correct 325 ms 23080 KB Output is correct
89 Correct 291 ms 22976 KB Output is correct
90 Correct 321 ms 23188 KB Output is correct
91 Correct 290 ms 22912 KB Output is correct
92 Correct 348 ms 23336 KB Output is correct
93 Correct 311 ms 23192 KB Output is correct
94 Correct 366 ms 23160 KB Output is correct
95 Correct 153 ms 17792 KB Output is correct
96 Correct 176 ms 23176 KB Output is correct
97 Correct 49 ms 3388 KB Output is correct
98 Correct 150 ms 23116 KB Output is correct
99 Correct 181 ms 23120 KB Output is correct