답안 #552662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
552662 2022-04-23T14:00:37 Z GioChkhaidze Team Contest (JOI22_team) C++14
100 / 100
939 ms 72716 KB
#include <bits/stdc++.h>
 
#define lf (h << 1)
#define mf ((l + r) >> 1)
#define rf ((h << 1) | 1)
#define tree int h, int l, int r
#define left lf, l, mf
#define right rf, mf + 1, r
#define ll long long
#define pb push_back
#define f first
#define s second
 
using namespace std;
 
const int N = 150005;
 
int n, x[N], y[N], z[N], Ox[N], Oy[N], Oz[N];
vector < int > vx[N], vy[N], vz[N];
vector < pair < int , int > > G[N];
int v[5 * N][3];
 
inline void upd(tree, int id, int vl, bool tp) {
	if (r < id || id < l) return ;
	if (l == id && id == r) {
		v[h][tp] = max(v[h][tp], vl);
		return ;
	}
	upd(left, id, vl, tp);
	upd(right, id, vl, tp);
	v[h][tp] = max(v[lf][tp], v[rf][tp]);
}

inline int get(tree, int L, int R, bool tp) {
	if (r < L || R < l) return 0;
	if (L <= l && r <= R) return v[h][tp];
	return max(get(left, L, R, tp), get(right, L, R, tp));
}

main () {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	
	cin >> n;
	vector < int > sx, sy, sz, s;
	map < int , int > fx, fy, fz;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i] >> z[i];
		sx.pb(x[i]);
		sy.pb(y[i]);
		sz.pb(z[i]);
		s.pb(i);
	}
	sort(sx.begin(), sx.end());
	sort(sy.begin(), sy.end());
	sort(sz.begin(), sz.end());
	sx.erase(unique(sx.begin(), sx.end()), sx.end());
	sy.erase(unique(sy.begin(), sy.end()), sy.end());
	sz.erase(unique(sz.begin(), sz.end()), sz.end());
	for (int i = 0; i < sx.size(); ++i) fx[sx[i]] = i + 1, Ox[i + 1] = sx[i];
	for (int i = 0; i < sy.size(); ++i) fy[sy[i]] = i + 1, Oy[i + 1] = sy[i];
	for (int i = 0; i < sz.size(); ++i) fz[sz[i]] = i + 1, Oz[i + 1] = sz[i];
	
	for (int i = 1; i <= n; ++i) {
		x[i] = fx[x[i]];
		y[i] = fy[y[i]];
		z[i] = fz[z[i]];
	}

	for (int i = 1; i <= n; ++i) {
		vx[x[i]].pb(i);
		vy[y[i]].pb(i);
		vz[z[i]].pb(i);
	}
	
	for (int i = 1; i <= sx.size(); ++i) {
		for (int j = 0; j < vx[i].size(); ++j) {
			int id = vx[i][j];	
			upd(1, 1, sy.size(), y[id], z[id], 0);
			upd(1, 1, sz.size(), z[id], y[id], 1);
		}
		
		for (int j = 0; j < vx[i].size(); ++j) {
			int id = vx[i][j];
			int Z = get(1, 1, sy.size(), 1, y[id] - 1, 0); 
			int Y = get(1, 1, sz.size(), 1, z[id] - 1, 1);

			if (z[id] < Z) {
				G[y[id]].pb({x[id], Z});
 			}
			
			if (y[id] < Y) {
				G[Y].pb({x[id], z[id]});
			}
		}
	}
	
	for (int i = 1; i <= 5 * n; ++i) {
		v[i][0] = v[i][1] = 0;
	}
	
	int ans = -1;
	for (int i = 1; i <= sy.size(); ++i) {
		for (int j = 0; j < G[i].size(); ++j) {
			int xid = G[i][j].f, zid = G[i][j].s;
			int X = get(1, 1, sz.size(), 1, zid - 1, 1);
			if (xid < X) {
				ans = max(ans, Ox[X] + Oy[i] + Oz[zid]);
			}
		}
		for (int j = 0; j < vy[i].size(); ++j) {
			int id = vy[i][j];
			upd(1, 1, sz.size(), z[id], x[id], 1);
		}
	}
	
	cout << ans << "\n";
}

Compilation message

team.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main () {
      | ^~~~
team.cpp: In function 'int main()':
team.cpp:60:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |  for (int i = 0; i < sx.size(); ++i) fx[sx[i]] = i + 1, Ox[i + 1] = sx[i];
      |                  ~~^~~~~~~~~~~
team.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  for (int i = 0; i < sy.size(); ++i) fy[sy[i]] = i + 1, Oy[i + 1] = sy[i];
      |                  ~~^~~~~~~~~~~
team.cpp:62:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |  for (int i = 0; i < sz.size(); ++i) fz[sz[i]] = i + 1, Oz[i + 1] = sz[i];
      |                  ~~^~~~~~~~~~~
team.cpp:76:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |  for (int i = 1; i <= sx.size(); ++i) {
      |                  ~~^~~~~~~~~~~~
team.cpp:77:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |   for (int j = 0; j < vx[i].size(); ++j) {
      |                   ~~^~~~~~~~~~~~~~
team.cpp:83:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |   for (int j = 0; j < vx[i].size(); ++j) {
      |                   ~~^~~~~~~~~~~~~~
team.cpp:103:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |  for (int i = 1; i <= sy.size(); ++i) {
      |                  ~~^~~~~~~~~~~~
team.cpp:104:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  104 |   for (int j = 0; j < G[i].size(); ++j) {
      |                   ~~^~~~~~~~~~~~~
team.cpp:111:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  111 |   for (int j = 0; j < vy[i].size(); ++j) {
      |                   ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 9 ms 14428 KB Output is correct
3 Correct 8 ms 14420 KB Output is correct
4 Correct 8 ms 14380 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 8 ms 14420 KB Output is correct
7 Correct 7 ms 14420 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14440 KB Output is correct
11 Correct 8 ms 14444 KB Output is correct
12 Correct 10 ms 14328 KB Output is correct
13 Correct 9 ms 14420 KB Output is correct
14 Correct 9 ms 14548 KB Output is correct
15 Correct 10 ms 14432 KB Output is correct
16 Correct 9 ms 14504 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14432 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 9 ms 14548 KB Output is correct
23 Correct 8 ms 14440 KB Output is correct
24 Correct 8 ms 14516 KB Output is correct
25 Correct 8 ms 14456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 9 ms 14428 KB Output is correct
3 Correct 8 ms 14420 KB Output is correct
4 Correct 8 ms 14380 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 8 ms 14420 KB Output is correct
7 Correct 7 ms 14420 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14440 KB Output is correct
11 Correct 8 ms 14444 KB Output is correct
12 Correct 10 ms 14328 KB Output is correct
13 Correct 9 ms 14420 KB Output is correct
14 Correct 9 ms 14548 KB Output is correct
15 Correct 10 ms 14432 KB Output is correct
16 Correct 9 ms 14504 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14432 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 9 ms 14548 KB Output is correct
23 Correct 8 ms 14440 KB Output is correct
24 Correct 8 ms 14516 KB Output is correct
25 Correct 8 ms 14456 KB Output is correct
26 Correct 21 ms 15956 KB Output is correct
27 Correct 16 ms 15552 KB Output is correct
28 Correct 18 ms 15444 KB Output is correct
29 Correct 17 ms 15272 KB Output is correct
30 Correct 14 ms 15060 KB Output is correct
31 Correct 17 ms 15168 KB Output is correct
32 Correct 12 ms 14932 KB Output is correct
33 Correct 13 ms 15060 KB Output is correct
34 Correct 17 ms 15784 KB Output is correct
35 Correct 8 ms 14548 KB Output is correct
36 Correct 9 ms 14564 KB Output is correct
37 Correct 11 ms 15188 KB Output is correct
38 Correct 12 ms 15128 KB Output is correct
39 Correct 9 ms 14684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 7 ms 14424 KB Output is correct
4 Correct 8 ms 14404 KB Output is correct
5 Correct 7 ms 14324 KB Output is correct
6 Correct 10 ms 14420 KB Output is correct
7 Correct 8 ms 14436 KB Output is correct
8 Correct 8 ms 14420 KB Output is correct
9 Correct 8 ms 14328 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 76 ms 32036 KB Output is correct
12 Correct 51 ms 25792 KB Output is correct
13 Correct 51 ms 27696 KB Output is correct
14 Correct 75 ms 32184 KB Output is correct
15 Correct 63 ms 31712 KB Output is correct
16 Correct 52 ms 29856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 7 ms 14424 KB Output is correct
4 Correct 8 ms 14404 KB Output is correct
5 Correct 7 ms 14324 KB Output is correct
6 Correct 10 ms 14420 KB Output is correct
7 Correct 8 ms 14436 KB Output is correct
8 Correct 8 ms 14420 KB Output is correct
9 Correct 8 ms 14328 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 76 ms 32036 KB Output is correct
12 Correct 51 ms 25792 KB Output is correct
13 Correct 51 ms 27696 KB Output is correct
14 Correct 75 ms 32184 KB Output is correct
15 Correct 63 ms 31712 KB Output is correct
16 Correct 52 ms 29856 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 7 ms 14424 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 10 ms 14628 KB Output is correct
22 Correct 111 ms 32620 KB Output is correct
23 Correct 95 ms 31836 KB Output is correct
24 Correct 73 ms 27116 KB Output is correct
25 Correct 111 ms 32036 KB Output is correct
26 Correct 69 ms 31936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 7 ms 14424 KB Output is correct
4 Correct 8 ms 14404 KB Output is correct
5 Correct 7 ms 14324 KB Output is correct
6 Correct 10 ms 14420 KB Output is correct
7 Correct 8 ms 14436 KB Output is correct
8 Correct 8 ms 14420 KB Output is correct
9 Correct 8 ms 14328 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 76 ms 32036 KB Output is correct
12 Correct 51 ms 25792 KB Output is correct
13 Correct 51 ms 27696 KB Output is correct
14 Correct 75 ms 32184 KB Output is correct
15 Correct 63 ms 31712 KB Output is correct
16 Correct 52 ms 29856 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 7 ms 14424 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 10 ms 14628 KB Output is correct
22 Correct 111 ms 32620 KB Output is correct
23 Correct 95 ms 31836 KB Output is correct
24 Correct 73 ms 27116 KB Output is correct
25 Correct 111 ms 32036 KB Output is correct
26 Correct 69 ms 31936 KB Output is correct
27 Correct 9 ms 14420 KB Output is correct
28 Correct 8 ms 14456 KB Output is correct
29 Correct 7 ms 14420 KB Output is correct
30 Correct 10 ms 14420 KB Output is correct
31 Correct 14 ms 14932 KB Output is correct
32 Correct 10 ms 14564 KB Output is correct
33 Correct 12 ms 14540 KB Output is correct
34 Correct 190 ms 32784 KB Output is correct
35 Correct 175 ms 32040 KB Output is correct
36 Correct 184 ms 33720 KB Output is correct
37 Correct 169 ms 32896 KB Output is correct
38 Correct 115 ms 32008 KB Output is correct
39 Correct 94 ms 26352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 8 ms 14420 KB Output is correct
3 Correct 7 ms 14424 KB Output is correct
4 Correct 8 ms 14404 KB Output is correct
5 Correct 7 ms 14324 KB Output is correct
6 Correct 10 ms 14420 KB Output is correct
7 Correct 8 ms 14436 KB Output is correct
8 Correct 8 ms 14420 KB Output is correct
9 Correct 8 ms 14328 KB Output is correct
10 Correct 8 ms 14420 KB Output is correct
11 Correct 76 ms 32036 KB Output is correct
12 Correct 51 ms 25792 KB Output is correct
13 Correct 51 ms 27696 KB Output is correct
14 Correct 75 ms 32184 KB Output is correct
15 Correct 63 ms 31712 KB Output is correct
16 Correct 52 ms 29856 KB Output is correct
17 Correct 7 ms 14420 KB Output is correct
18 Correct 7 ms 14424 KB Output is correct
19 Correct 8 ms 14420 KB Output is correct
20 Correct 8 ms 14424 KB Output is correct
21 Correct 10 ms 14628 KB Output is correct
22 Correct 111 ms 32620 KB Output is correct
23 Correct 95 ms 31836 KB Output is correct
24 Correct 73 ms 27116 KB Output is correct
25 Correct 111 ms 32036 KB Output is correct
26 Correct 69 ms 31936 KB Output is correct
27 Correct 9 ms 14420 KB Output is correct
28 Correct 8 ms 14456 KB Output is correct
29 Correct 7 ms 14420 KB Output is correct
30 Correct 10 ms 14420 KB Output is correct
31 Correct 14 ms 14932 KB Output is correct
32 Correct 10 ms 14564 KB Output is correct
33 Correct 12 ms 14540 KB Output is correct
34 Correct 190 ms 32784 KB Output is correct
35 Correct 175 ms 32040 KB Output is correct
36 Correct 184 ms 33720 KB Output is correct
37 Correct 169 ms 32896 KB Output is correct
38 Correct 115 ms 32008 KB Output is correct
39 Correct 94 ms 26352 KB Output is correct
40 Correct 16 ms 15084 KB Output is correct
41 Correct 17 ms 15216 KB Output is correct
42 Correct 13 ms 15060 KB Output is correct
43 Correct 16 ms 15076 KB Output is correct
44 Correct 323 ms 36536 KB Output is correct
45 Correct 251 ms 34356 KB Output is correct
46 Correct 288 ms 34732 KB Output is correct
47 Correct 254 ms 34492 KB Output is correct
48 Correct 169 ms 33680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 14420 KB Output is correct
2 Correct 9 ms 14428 KB Output is correct
3 Correct 8 ms 14420 KB Output is correct
4 Correct 8 ms 14380 KB Output is correct
5 Correct 8 ms 14420 KB Output is correct
6 Correct 8 ms 14420 KB Output is correct
7 Correct 7 ms 14420 KB Output is correct
8 Correct 7 ms 14420 KB Output is correct
9 Correct 8 ms 14420 KB Output is correct
10 Correct 8 ms 14440 KB Output is correct
11 Correct 8 ms 14444 KB Output is correct
12 Correct 10 ms 14328 KB Output is correct
13 Correct 9 ms 14420 KB Output is correct
14 Correct 9 ms 14548 KB Output is correct
15 Correct 10 ms 14432 KB Output is correct
16 Correct 9 ms 14504 KB Output is correct
17 Correct 8 ms 14420 KB Output is correct
18 Correct 8 ms 14432 KB Output is correct
19 Correct 9 ms 14548 KB Output is correct
20 Correct 9 ms 14420 KB Output is correct
21 Correct 8 ms 14420 KB Output is correct
22 Correct 9 ms 14548 KB Output is correct
23 Correct 8 ms 14440 KB Output is correct
24 Correct 8 ms 14516 KB Output is correct
25 Correct 8 ms 14456 KB Output is correct
26 Correct 21 ms 15956 KB Output is correct
27 Correct 16 ms 15552 KB Output is correct
28 Correct 18 ms 15444 KB Output is correct
29 Correct 17 ms 15272 KB Output is correct
30 Correct 14 ms 15060 KB Output is correct
31 Correct 17 ms 15168 KB Output is correct
32 Correct 12 ms 14932 KB Output is correct
33 Correct 13 ms 15060 KB Output is correct
34 Correct 17 ms 15784 KB Output is correct
35 Correct 8 ms 14548 KB Output is correct
36 Correct 9 ms 14564 KB Output is correct
37 Correct 11 ms 15188 KB Output is correct
38 Correct 12 ms 15128 KB Output is correct
39 Correct 9 ms 14684 KB Output is correct
40 Correct 8 ms 14420 KB Output is correct
41 Correct 8 ms 14420 KB Output is correct
42 Correct 7 ms 14424 KB Output is correct
43 Correct 8 ms 14404 KB Output is correct
44 Correct 7 ms 14324 KB Output is correct
45 Correct 10 ms 14420 KB Output is correct
46 Correct 8 ms 14436 KB Output is correct
47 Correct 8 ms 14420 KB Output is correct
48 Correct 8 ms 14328 KB Output is correct
49 Correct 8 ms 14420 KB Output is correct
50 Correct 76 ms 32036 KB Output is correct
51 Correct 51 ms 25792 KB Output is correct
52 Correct 51 ms 27696 KB Output is correct
53 Correct 75 ms 32184 KB Output is correct
54 Correct 63 ms 31712 KB Output is correct
55 Correct 52 ms 29856 KB Output is correct
56 Correct 7 ms 14420 KB Output is correct
57 Correct 7 ms 14424 KB Output is correct
58 Correct 8 ms 14420 KB Output is correct
59 Correct 8 ms 14424 KB Output is correct
60 Correct 10 ms 14628 KB Output is correct
61 Correct 111 ms 32620 KB Output is correct
62 Correct 95 ms 31836 KB Output is correct
63 Correct 73 ms 27116 KB Output is correct
64 Correct 111 ms 32036 KB Output is correct
65 Correct 69 ms 31936 KB Output is correct
66 Correct 9 ms 14420 KB Output is correct
67 Correct 8 ms 14456 KB Output is correct
68 Correct 7 ms 14420 KB Output is correct
69 Correct 10 ms 14420 KB Output is correct
70 Correct 14 ms 14932 KB Output is correct
71 Correct 10 ms 14564 KB Output is correct
72 Correct 12 ms 14540 KB Output is correct
73 Correct 190 ms 32784 KB Output is correct
74 Correct 175 ms 32040 KB Output is correct
75 Correct 184 ms 33720 KB Output is correct
76 Correct 169 ms 32896 KB Output is correct
77 Correct 115 ms 32008 KB Output is correct
78 Correct 94 ms 26352 KB Output is correct
79 Correct 16 ms 15084 KB Output is correct
80 Correct 17 ms 15216 KB Output is correct
81 Correct 13 ms 15060 KB Output is correct
82 Correct 16 ms 15076 KB Output is correct
83 Correct 323 ms 36536 KB Output is correct
84 Correct 251 ms 34356 KB Output is correct
85 Correct 288 ms 34732 KB Output is correct
86 Correct 254 ms 34492 KB Output is correct
87 Correct 169 ms 33680 KB Output is correct
88 Correct 939 ms 72716 KB Output is correct
89 Correct 648 ms 52812 KB Output is correct
90 Correct 664 ms 58704 KB Output is correct
91 Correct 482 ms 47420 KB Output is correct
92 Correct 364 ms 40096 KB Output is correct
93 Correct 551 ms 54300 KB Output is correct
94 Correct 425 ms 45692 KB Output is correct
95 Correct 261 ms 42296 KB Output is correct
96 Correct 647 ms 67840 KB Output is correct
97 Correct 72 ms 31868 KB Output is correct
98 Correct 193 ms 42788 KB Output is correct
99 Correct 222 ms 42892 KB Output is correct