답안 #740420

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
740420 2023-05-12T12:38:37 Z Dan4Life Team Contest (JOI22_team) C++17
100 / 100
240 ms 8680 KB
#include <bits/stdc++.h>
using namespace std;
#define fr(i) for(int i = 0; i < 3; i++)
#define V(x,y) V[x][i[x]][y]
#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> V[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) V[j].pb({x,y,z,i});
	}
	fr(j) sort(all(V[j]),[&](ar a, ar b){ return a[j] < b[j]; });
	while(1){
		fr(j){
			while(i[j]>=0 and bad[V(j,3)]) i[j]--; 
			if(i[j]<0){cout<<-1;return 0;}
		}
		vector<int> v; v.clear();
		fr(j) v.pb(V(j,j));
		fr(I) fr(j) if(I!=j and V(I,j)==v[j]) bad[V(I,3)]=1;
		bool ok = 1; fr(j) ok&=!bad[V(j,3)];
		if(ok){ cout << v[0]+v[1]+v[2]; return 0; }
	}
}
# 결과 실행 시간 메모리 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 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 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 212 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 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 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 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 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 212 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 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 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 6 ms 564 KB Output is correct
27 Correct 6 ms 548 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 7 ms 560 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 7 ms 468 KB Output is correct
34 Correct 7 ms 564 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 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 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 91 ms 8660 KB Output is correct
12 Correct 67 ms 5136 KB Output is correct
13 Correct 70 ms 6260 KB Output is correct
14 Correct 125 ms 8616 KB Output is correct
15 Correct 97 ms 8636 KB Output is correct
16 Correct 103 ms 8560 KB Output is correct
# 결과 실행 시간 메모리 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 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 91 ms 8660 KB Output is correct
12 Correct 67 ms 5136 KB Output is correct
13 Correct 70 ms 6260 KB Output is correct
14 Correct 125 ms 8616 KB Output is correct
15 Correct 97 ms 8636 KB Output is correct
16 Correct 103 ms 8560 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 0 ms 340 KB Output is correct
21 Correct 2 ms 388 KB Output is correct
22 Correct 107 ms 8564 KB Output is correct
23 Correct 97 ms 8676 KB Output is correct
24 Correct 78 ms 5540 KB Output is correct
25 Correct 122 ms 8588 KB Output is correct
26 Correct 99 ms 8564 KB Output is correct
# 결과 실행 시간 메모리 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 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 91 ms 8660 KB Output is correct
12 Correct 67 ms 5136 KB Output is correct
13 Correct 70 ms 6260 KB Output is correct
14 Correct 125 ms 8616 KB Output is correct
15 Correct 97 ms 8636 KB Output is correct
16 Correct 103 ms 8560 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 0 ms 340 KB Output is correct
21 Correct 2 ms 388 KB Output is correct
22 Correct 107 ms 8564 KB Output is correct
23 Correct 97 ms 8676 KB Output is correct
24 Correct 78 ms 5540 KB Output is correct
25 Correct 122 ms 8588 KB Output is correct
26 Correct 99 ms 8564 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 123 ms 8568 KB Output is correct
35 Correct 127 ms 8680 KB Output is correct
36 Correct 135 ms 8620 KB Output is correct
37 Correct 143 ms 8620 KB Output is correct
38 Correct 119 ms 8620 KB Output is correct
39 Correct 72 ms 4668 KB Output is correct
# 결과 실행 시간 메모리 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 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 91 ms 8660 KB Output is correct
12 Correct 67 ms 5136 KB Output is correct
13 Correct 70 ms 6260 KB Output is correct
14 Correct 125 ms 8616 KB Output is correct
15 Correct 97 ms 8636 KB Output is correct
16 Correct 103 ms 8560 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 0 ms 340 KB Output is correct
21 Correct 2 ms 388 KB Output is correct
22 Correct 107 ms 8564 KB Output is correct
23 Correct 97 ms 8676 KB Output is correct
24 Correct 78 ms 5540 KB Output is correct
25 Correct 122 ms 8588 KB Output is correct
26 Correct 99 ms 8564 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 123 ms 8568 KB Output is correct
35 Correct 127 ms 8680 KB Output is correct
36 Correct 135 ms 8620 KB Output is correct
37 Correct 143 ms 8620 KB Output is correct
38 Correct 119 ms 8620 KB Output is correct
39 Correct 72 ms 4668 KB Output is correct
40 Correct 3 ms 468 KB Output is correct
41 Correct 4 ms 468 KB Output is correct
42 Correct 3 ms 468 KB Output is correct
43 Correct 5 ms 468 KB Output is correct
44 Correct 150 ms 8592 KB Output is correct
45 Correct 168 ms 8620 KB Output is correct
46 Correct 180 ms 8628 KB Output is correct
47 Correct 170 ms 8572 KB Output is correct
48 Correct 140 ms 8552 KB Output is correct
# 결과 실행 시간 메모리 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 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 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 212 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 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 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 6 ms 564 KB Output is correct
27 Correct 6 ms 548 KB Output is correct
28 Correct 6 ms 468 KB Output is correct
29 Correct 7 ms 560 KB Output is correct
30 Correct 5 ms 468 KB Output is correct
31 Correct 4 ms 468 KB Output is correct
32 Correct 4 ms 468 KB Output is correct
33 Correct 7 ms 468 KB Output is correct
34 Correct 7 ms 564 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 468 KB Output is correct
38 Correct 5 ms 468 KB Output is correct
39 Correct 2 ms 340 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 0 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 91 ms 8660 KB Output is correct
51 Correct 67 ms 5136 KB Output is correct
52 Correct 70 ms 6260 KB Output is correct
53 Correct 125 ms 8616 KB Output is correct
54 Correct 97 ms 8636 KB Output is correct
55 Correct 103 ms 8560 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 0 ms 340 KB Output is correct
60 Correct 2 ms 388 KB Output is correct
61 Correct 107 ms 8564 KB Output is correct
62 Correct 97 ms 8676 KB Output is correct
63 Correct 78 ms 5540 KB Output is correct
64 Correct 122 ms 8588 KB Output is correct
65 Correct 99 ms 8564 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 0 ms 340 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 4 ms 468 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 123 ms 8568 KB Output is correct
74 Correct 127 ms 8680 KB Output is correct
75 Correct 135 ms 8620 KB Output is correct
76 Correct 143 ms 8620 KB Output is correct
77 Correct 119 ms 8620 KB Output is correct
78 Correct 72 ms 4668 KB Output is correct
79 Correct 3 ms 468 KB Output is correct
80 Correct 4 ms 468 KB Output is correct
81 Correct 3 ms 468 KB Output is correct
82 Correct 5 ms 468 KB Output is correct
83 Correct 150 ms 8592 KB Output is correct
84 Correct 168 ms 8620 KB Output is correct
85 Correct 180 ms 8628 KB Output is correct
86 Correct 170 ms 8572 KB Output is correct
87 Correct 140 ms 8552 KB Output is correct
88 Correct 213 ms 8628 KB Output is correct
89 Correct 213 ms 8584 KB Output is correct
90 Correct 208 ms 8584 KB Output is correct
91 Correct 223 ms 8600 KB Output is correct
92 Correct 164 ms 8560 KB Output is correct
93 Correct 202 ms 8664 KB Output is correct
94 Correct 185 ms 8660 KB Output is correct
95 Correct 182 ms 8656 KB Output is correct
96 Correct 240 ms 8652 KB Output is correct
97 Correct 191 ms 8632 KB Output is correct
98 Correct 128 ms 8572 KB Output is correct
99 Correct 228 ms 8620 KB Output is correct