Submission #740411

# Submission time Handle Problem Language Result Execution time Memory
740411 2023-05-12T12:30:48 Z Dan4Life Team Contest (JOI22_team) C++17
100 / 100
245 ms 17076 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define all(a) a.begin(),a.end()
const int mxN = (int)1.5e5+10;
using ar = array<int,4>;
vector<ar> coder[3];
bool bad[mxN];
int n;

int32_t main() {
	cin >> n;
	for(int i = 0; i < n; i++){
		int x,y,z; cin >>x>>y>>z;
		for(int j = 0; j < 3; j++) coder[j].pb({x,y,z,i});
	}
	for(int j = 0; j < 3; j++) 
		sort(all(coder[j]),[&](ar a, ar b){ return a[j] < b[j]; });
	int i[] = {n-1,n-1,n-1};
	while(1){
		for(int j = 0; j < 3; j++){
			while(i[j]>=0 and bad[coder[j][i[j]][3]]) i[j]--; 
			if(i[j]<0){cout<<-1;return 0;}
		}
		vector<int> val; val.clear();
		for(int j = 0; j < 3; j++) val.pb(coder[j][i[j]][j]);
		for(int I = 0; I < 3; I++)
			for(int j = 0; j < 3; j++)
				if(I!=j and coder[I][i[I]][j]==val[j])
					bad[coder[I][i[I]][3]]=1;
		bool ok = 1;
		for(int j = 0; j < 3; j++) ok&=!bad[coder[j][i[j]][3]];
		if(ok){ cout << val[0]+val[1]+val[2]; return 0; }
	}
}
# 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 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 340 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 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 340 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 6 ms 724 KB Output is correct
27 Correct 6 ms 724 KB Output is correct
28 Correct 6 ms 724 KB Output is correct
29 Correct 6 ms 724 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 724 KB Output is correct
32 Correct 6 ms 768 KB Output is correct
33 Correct 5 ms 820 KB Output is correct
34 Correct 7 ms 724 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 724 KB Output is correct
38 Correct 6 ms 836 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 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 121 ms 16772 KB Output is correct
12 Correct 75 ms 9936 KB Output is correct
13 Correct 83 ms 12036 KB Output is correct
14 Correct 115 ms 16860 KB Output is correct
15 Correct 112 ms 16868 KB Output is correct
16 Correct 111 ms 16776 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 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 121 ms 16772 KB Output is correct
12 Correct 75 ms 9936 KB Output is correct
13 Correct 83 ms 12036 KB Output is correct
14 Correct 115 ms 16860 KB Output is correct
15 Correct 112 ms 16868 KB Output is correct
16 Correct 111 ms 16776 KB Output is correct
17 Correct 1 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 340 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 112 ms 16824 KB Output is correct
23 Correct 127 ms 16908 KB Output is correct
24 Correct 86 ms 10644 KB Output is correct
25 Correct 129 ms 16880 KB Output is correct
26 Correct 109 ms 17076 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 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 121 ms 16772 KB Output is correct
12 Correct 75 ms 9936 KB Output is correct
13 Correct 83 ms 12036 KB Output is correct
14 Correct 115 ms 16860 KB Output is correct
15 Correct 112 ms 16868 KB Output is correct
16 Correct 111 ms 16776 KB Output is correct
17 Correct 1 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 340 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 112 ms 16824 KB Output is correct
23 Correct 127 ms 16908 KB Output is correct
24 Correct 86 ms 10644 KB Output is correct
25 Correct 129 ms 16880 KB Output is correct
26 Correct 109 ms 17076 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 796 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 130 ms 16792 KB Output is correct
35 Correct 131 ms 16876 KB Output is correct
36 Correct 141 ms 16784 KB Output is correct
37 Correct 157 ms 16848 KB Output is correct
38 Correct 126 ms 16860 KB Output is correct
39 Correct 78 ms 8904 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 0 ms 212 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 121 ms 16772 KB Output is correct
12 Correct 75 ms 9936 KB Output is correct
13 Correct 83 ms 12036 KB Output is correct
14 Correct 115 ms 16860 KB Output is correct
15 Correct 112 ms 16868 KB Output is correct
16 Correct 111 ms 16776 KB Output is correct
17 Correct 1 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 340 KB Output is correct
21 Correct 2 ms 468 KB Output is correct
22 Correct 112 ms 16824 KB Output is correct
23 Correct 127 ms 16908 KB Output is correct
24 Correct 86 ms 10644 KB Output is correct
25 Correct 129 ms 16880 KB Output is correct
26 Correct 109 ms 17076 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 796 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 130 ms 16792 KB Output is correct
35 Correct 131 ms 16876 KB Output is correct
36 Correct 141 ms 16784 KB Output is correct
37 Correct 157 ms 16848 KB Output is correct
38 Correct 126 ms 16860 KB Output is correct
39 Correct 78 ms 8904 KB Output is correct
40 Correct 4 ms 724 KB Output is correct
41 Correct 5 ms 836 KB Output is correct
42 Correct 3 ms 724 KB Output is correct
43 Correct 5 ms 724 KB Output is correct
44 Correct 159 ms 16780 KB Output is correct
45 Correct 174 ms 16816 KB Output is correct
46 Correct 168 ms 16944 KB Output is correct
47 Correct 169 ms 16856 KB Output is correct
48 Correct 145 ms 16848 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 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 340 KB Output is correct
16 Correct 1 ms 340 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 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 6 ms 724 KB Output is correct
27 Correct 6 ms 724 KB Output is correct
28 Correct 6 ms 724 KB Output is correct
29 Correct 6 ms 724 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 4 ms 724 KB Output is correct
32 Correct 6 ms 768 KB Output is correct
33 Correct 5 ms 820 KB Output is correct
34 Correct 7 ms 724 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 724 KB Output is correct
38 Correct 6 ms 836 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 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 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 121 ms 16772 KB Output is correct
51 Correct 75 ms 9936 KB Output is correct
52 Correct 83 ms 12036 KB Output is correct
53 Correct 115 ms 16860 KB Output is correct
54 Correct 112 ms 16868 KB Output is correct
55 Correct 111 ms 16776 KB Output is correct
56 Correct 1 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 340 KB Output is correct
60 Correct 2 ms 468 KB Output is correct
61 Correct 112 ms 16824 KB Output is correct
62 Correct 127 ms 16908 KB Output is correct
63 Correct 86 ms 10644 KB Output is correct
64 Correct 129 ms 16880 KB Output is correct
65 Correct 109 ms 17076 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 796 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 2 ms 340 KB Output is correct
73 Correct 130 ms 16792 KB Output is correct
74 Correct 131 ms 16876 KB Output is correct
75 Correct 141 ms 16784 KB Output is correct
76 Correct 157 ms 16848 KB Output is correct
77 Correct 126 ms 16860 KB Output is correct
78 Correct 78 ms 8904 KB Output is correct
79 Correct 4 ms 724 KB Output is correct
80 Correct 5 ms 836 KB Output is correct
81 Correct 3 ms 724 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 159 ms 16780 KB Output is correct
84 Correct 174 ms 16816 KB Output is correct
85 Correct 168 ms 16944 KB Output is correct
86 Correct 169 ms 16856 KB Output is correct
87 Correct 145 ms 16848 KB Output is correct
88 Correct 219 ms 16856 KB Output is correct
89 Correct 231 ms 16804 KB Output is correct
90 Correct 230 ms 16796 KB Output is correct
91 Correct 241 ms 16872 KB Output is correct
92 Correct 182 ms 16992 KB Output is correct
93 Correct 200 ms 16856 KB Output is correct
94 Correct 194 ms 16784 KB Output is correct
95 Correct 200 ms 16880 KB Output is correct
96 Correct 245 ms 16848 KB Output is correct
97 Correct 205 ms 16824 KB Output is correct
98 Correct 171 ms 16900 KB Output is correct
99 Correct 222 ms 16868 KB Output is correct