Submission #740412

# Submission time Handle Problem Language Result Execution time Memory
740412 2023-05-12T12:35:04 Z Dan4Life Team Contest (JOI22_team) C++17
100 / 100
222 ms 8680 KB
#include <bits/stdc++.h>
using namespace std;
#define fr(i) for(int i = 0; i < 3; i++)
#define pb push_back
#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; int i[] = {n-1,n-1,n-1};
	for(int i = 0; i < n; i++){
		int x,y,z; cin >>x>>y>>z;
		fr(j) coder[j].pb({x,y,z,i});
	}
	fr(j) sort(all(coder[j]),[&](ar a, ar b){ return a[j] < b[j]; });
	while(1){
		fr(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();
		fr(j) val.pb(coder[j][i[j]][j]);
		fr(I) fr(j) 
			if(I!=j and coder[I][i[I]][j]==val[j]) 
				bad[coder[I][i[I]][3]]=1;
		bool ok = 1;
		fr(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 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 1 ms 212 KB Output is correct
12 Correct 1 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 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 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 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 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 1 ms 212 KB Output is correct
12 Correct 1 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 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 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 6 ms 544 KB Output is correct
28 Correct 6 ms 472 KB Output is correct
29 Correct 6 ms 572 KB Output is correct
30 Correct 5 ms 588 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 6 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 4 ms 596 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 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 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 88 ms 8612 KB Output is correct
12 Correct 65 ms 5140 KB Output is correct
13 Correct 70 ms 6236 KB Output is correct
14 Correct 102 ms 8604 KB Output is correct
15 Correct 92 ms 8608 KB Output is correct
16 Correct 101 ms 8600 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 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 88 ms 8612 KB Output is correct
12 Correct 65 ms 5140 KB Output is correct
13 Correct 70 ms 6236 KB Output is correct
14 Correct 102 ms 8604 KB Output is correct
15 Correct 92 ms 8608 KB Output is correct
16 Correct 101 ms 8600 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 1 ms 340 KB Output is correct
22 Correct 106 ms 8640 KB Output is correct
23 Correct 99 ms 8580 KB Output is correct
24 Correct 84 ms 5616 KB Output is correct
25 Correct 116 ms 8628 KB Output is correct
26 Correct 102 ms 8612 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 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 88 ms 8612 KB Output is correct
12 Correct 65 ms 5140 KB Output is correct
13 Correct 70 ms 6236 KB Output is correct
14 Correct 102 ms 8604 KB Output is correct
15 Correct 92 ms 8608 KB Output is correct
16 Correct 101 ms 8600 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 1 ms 340 KB Output is correct
22 Correct 106 ms 8640 KB Output is correct
23 Correct 99 ms 8580 KB Output is correct
24 Correct 84 ms 5616 KB Output is correct
25 Correct 116 ms 8628 KB Output is correct
26 Correct 102 ms 8612 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 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 136 ms 8604 KB Output is correct
35 Correct 135 ms 8668 KB Output is correct
36 Correct 142 ms 8640 KB Output is correct
37 Correct 145 ms 8640 KB Output is correct
38 Correct 118 ms 8584 KB Output is correct
39 Correct 71 ms 4632 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 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 88 ms 8612 KB Output is correct
12 Correct 65 ms 5140 KB Output is correct
13 Correct 70 ms 6236 KB Output is correct
14 Correct 102 ms 8604 KB Output is correct
15 Correct 92 ms 8608 KB Output is correct
16 Correct 101 ms 8600 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 1 ms 340 KB Output is correct
22 Correct 106 ms 8640 KB Output is correct
23 Correct 99 ms 8580 KB Output is correct
24 Correct 84 ms 5616 KB Output is correct
25 Correct 116 ms 8628 KB Output is correct
26 Correct 102 ms 8612 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 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 2 ms 340 KB Output is correct
34 Correct 136 ms 8604 KB Output is correct
35 Correct 135 ms 8668 KB Output is correct
36 Correct 142 ms 8640 KB Output is correct
37 Correct 145 ms 8640 KB Output is correct
38 Correct 118 ms 8584 KB Output is correct
39 Correct 71 ms 4632 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 4 ms 468 KB Output is correct
42 Correct 5 ms 596 KB Output is correct
43 Correct 5 ms 468 KB Output is correct
44 Correct 154 ms 8612 KB Output is correct
45 Correct 173 ms 8604 KB Output is correct
46 Correct 172 ms 8616 KB Output is correct
47 Correct 171 ms 8636 KB Output is correct
48 Correct 149 ms 8580 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 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 1 ms 212 KB Output is correct
12 Correct 1 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 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 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 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 6 ms 468 KB Output is correct
27 Correct 6 ms 544 KB Output is correct
28 Correct 6 ms 472 KB Output is correct
29 Correct 6 ms 572 KB Output is correct
30 Correct 5 ms 588 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 5 ms 468 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 6 ms 468 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 4 ms 596 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
40 Correct 0 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 88 ms 8612 KB Output is correct
51 Correct 65 ms 5140 KB Output is correct
52 Correct 70 ms 6236 KB Output is correct
53 Correct 102 ms 8604 KB Output is correct
54 Correct 92 ms 8608 KB Output is correct
55 Correct 101 ms 8600 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 1 ms 340 KB Output is correct
61 Correct 106 ms 8640 KB Output is correct
62 Correct 99 ms 8580 KB Output is correct
63 Correct 84 ms 5616 KB Output is correct
64 Correct 116 ms 8628 KB Output is correct
65 Correct 102 ms 8612 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 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 2 ms 340 KB Output is correct
73 Correct 136 ms 8604 KB Output is correct
74 Correct 135 ms 8668 KB Output is correct
75 Correct 142 ms 8640 KB Output is correct
76 Correct 145 ms 8640 KB Output is correct
77 Correct 118 ms 8584 KB Output is correct
78 Correct 71 ms 4632 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 4 ms 468 KB Output is correct
81 Correct 5 ms 596 KB Output is correct
82 Correct 5 ms 468 KB Output is correct
83 Correct 154 ms 8612 KB Output is correct
84 Correct 173 ms 8604 KB Output is correct
85 Correct 172 ms 8616 KB Output is correct
86 Correct 171 ms 8636 KB Output is correct
87 Correct 149 ms 8580 KB Output is correct
88 Correct 215 ms 8556 KB Output is correct
89 Correct 220 ms 8628 KB Output is correct
90 Correct 212 ms 8612 KB Output is correct
91 Correct 217 ms 8680 KB Output is correct
92 Correct 171 ms 8572 KB Output is correct
93 Correct 182 ms 8656 KB Output is correct
94 Correct 187 ms 8612 KB Output is correct
95 Correct 181 ms 8628 KB Output is correct
96 Correct 222 ms 8612 KB Output is correct
97 Correct 196 ms 8616 KB Output is correct
98 Correct 132 ms 8592 KB Output is correct
99 Correct 213 ms 8648 KB Output is correct