Submission #567802

# Submission time Handle Problem Language Result Execution time Memory
567802 2022-05-24T08:29:13 Z maomao90 Team Contest (JOI22_team) C++17
17 / 100
2000 ms 2740 KB
#include <bits/stdc++.h>
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)

template <class T>
bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

#ifndef DEBUG
#define cerr if(0) cerr
#endif

const int MAXN = 150005;
const int INF = 1000000005;
const ll LINF = 1000000000000000005;

int n;
iii xyz[MAXN];
set<iii> st;
ii lft, rht;
int ans;

int main() {
#ifndef DEBUG
	ios::sync_with_stdio(0), cin.tie(0);
#endif
	cin >> n;
	REP (i, 0, n) {
		int x, y, z; cin >> x >> y >> z;
		xyz[i] = {x, y, z};
		st.insert(xyz[i]);
	}
	n = 0;
	for (iii i : st) {
		xyz[n++] = i;
	}
	ans = -1;
	int ptr = 0;
	lft = ii{-1, -1}, rht = ii{-1, -1};
	/*
	REP (i, 0, n) {
		while (ptr < i && get<1>(xyz[ptr]) < get<1>(xyz[i])) {
			auto [x, y, z] = xyz[ptr++];
			if (lft.FI != -1) {
				if (x > rht.FI && y < lft.SE) {
					rht = ii{x, z};
				} else if (y > lft.SE && x < rht.FI) {
					lft = ii{x, z};
				}
			}
			auto [it, yes] = st.insert(ii{x, z});
			if (!yes) {
				continue;
			}
			cerr << "+ " << x << ' ' << z << '\n';
			if (next(it) != st.end() && next(it) -> SE >= z) {
				it = st.erase(it);
				cerr << "- " << x << ' ' << z << '\n';
				assert(next(it) == st.end() || it -> FI != next(it) -> FI);
				assert(it == st.begin() || it -> FI != prev(it) -> FI);
				assert(next(it) == st.end() || it -> SE > next(it) -> SE);
				assert(it == st.begin() || it -> SE < prev(it) -> SE);
				continue;
			}
			while (it != st.begin() && prev(it) -> SE <= z) {
				cerr << "- " << prev(it) -> FI << ' ' << prev(it) -> SE << '\n';
				st.erase(prev(it));
			}
			assert(next(it) == st.end() || it -> FI != next(it) -> FI);
			assert(it == st.begin() || it -> FI != prev(it) -> FI);
			assert(next(it) == st.end() || it -> SE > next(it) -> SE);
			assert(it == st.begin() || it -> SE < prev(it) -> SE);
			if (SZ(st) >= 2) {
				lft = *st.begin();
				rht = *prev(st.end());
			}
		}
		if (SZ(st) >= 2) {
			int mx = prev(st.end()) -> FI, mz = st.begin() -> SE;
			int my = -INF;
			auto [cx, cy, cz] = xyz[i];
			if (cx < mx && cz < mz) {
				my = cy;
			}
			if (my != -INF) {
				mxto(ans, mx + my + mz);
			}
		}
		if (lft.FI != -1) {
			int mx = rht.FI, mz = lft.SE;
			int my = -INF;
			auto [cx, cy, cz] = xyz[i];
			if (cx < mx && cz < mz) {
				my = cy;
			}
			if (my != -INF) {
				mxto(ans, mx + my + mz);
			}
		}
	}
	*/
	REP (i, 0, n) {
		REP (j, 0, i) {
			REP (k, 0, j) {
				int g[3][3];
				g[0][0] = get<0>(xyz[i]);
				g[0][1] = get<1>(xyz[i]);
				g[0][2] = get<2>(xyz[i]);
				g[1][0] = get<0>(xyz[j]);
				g[1][1] = get<1>(xyz[j]);
				g[1][2] = get<2>(xyz[j]);
				g[2][0] = get<0>(xyz[k]);
				g[2][1] = get<1>(xyz[k]);
				g[2][2] = get<2>(xyz[k]);
				int cur = 0;
				int a[3] = {0, 0, 0};
				REP (z, 0, 3) {
					REP (l, 0, 3) {
						mxto(a[z], g[l][z]);
					}
					int occ = 0;
					REP (l, 0, 3) {
						occ += g[l][z] == a[z];
					}
					if (occ != 1) {
						cur = -1;
						break;
					}
					cur += a[z];
				}
				REP (z, 0, 3) {
					int occ = 0;
					REP (l, 0, 3) {
						occ += a[l] == g[z][l];
					}
					if (occ != 1) {
						cur = -1;
						break;
					}
				}
				mxto(ans, cur);
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:54:6: warning: unused variable 'ptr' [-Wunused-variable]
   54 |  int ptr = 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 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 0 ms 212 KB Output is correct
9 Correct 1 ms 328 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 1 ms 212 KB Output is correct
14 Correct 69 ms 340 KB Output is correct
15 Correct 28 ms 340 KB Output is correct
16 Correct 45 ms 340 KB Output is correct
17 Correct 50 ms 336 KB Output is correct
18 Correct 54 ms 340 KB Output is correct
19 Correct 66 ms 336 KB Output is correct
20 Correct 26 ms 340 KB Output is correct
21 Correct 21 ms 340 KB Output is correct
22 Correct 40 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 45 ms 340 KB Output is correct
25 Correct 42 ms 332 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 0 ms 212 KB Output is correct
9 Correct 1 ms 328 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 1 ms 212 KB Output is correct
14 Correct 69 ms 340 KB Output is correct
15 Correct 28 ms 340 KB Output is correct
16 Correct 45 ms 340 KB Output is correct
17 Correct 50 ms 336 KB Output is correct
18 Correct 54 ms 340 KB Output is correct
19 Correct 66 ms 336 KB Output is correct
20 Correct 26 ms 340 KB Output is correct
21 Correct 21 ms 340 KB Output is correct
22 Correct 40 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 45 ms 340 KB Output is correct
25 Correct 42 ms 332 KB Output is correct
26 Execution timed out 2093 ms 596 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 34 ms 2628 KB Output is correct
12 Correct 18 ms 1840 KB Output is correct
13 Correct 21 ms 2440 KB Output is correct
14 Correct 31 ms 2740 KB Output is correct
15 Correct 27 ms 2420 KB Output is correct
16 Correct 27 ms 2644 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 34 ms 2628 KB Output is correct
12 Correct 18 ms 1840 KB Output is correct
13 Correct 21 ms 2440 KB Output is correct
14 Correct 31 ms 2740 KB Output is correct
15 Correct 27 ms 2420 KB Output is correct
16 Correct 27 ms 2644 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 27 ms 340 KB Output is correct
21 Execution timed out 2081 ms 472 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 34 ms 2628 KB Output is correct
12 Correct 18 ms 1840 KB Output is correct
13 Correct 21 ms 2440 KB Output is correct
14 Correct 31 ms 2740 KB Output is correct
15 Correct 27 ms 2420 KB Output is correct
16 Correct 27 ms 2644 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 27 ms 340 KB Output is correct
21 Execution timed out 2081 ms 472 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 34 ms 2628 KB Output is correct
12 Correct 18 ms 1840 KB Output is correct
13 Correct 21 ms 2440 KB Output is correct
14 Correct 31 ms 2740 KB Output is correct
15 Correct 27 ms 2420 KB Output is correct
16 Correct 27 ms 2644 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 27 ms 340 KB Output is correct
21 Execution timed out 2081 ms 472 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 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 0 ms 212 KB Output is correct
9 Correct 1 ms 328 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 1 ms 212 KB Output is correct
14 Correct 69 ms 340 KB Output is correct
15 Correct 28 ms 340 KB Output is correct
16 Correct 45 ms 340 KB Output is correct
17 Correct 50 ms 336 KB Output is correct
18 Correct 54 ms 340 KB Output is correct
19 Correct 66 ms 336 KB Output is correct
20 Correct 26 ms 340 KB Output is correct
21 Correct 21 ms 340 KB Output is correct
22 Correct 40 ms 340 KB Output is correct
23 Correct 0 ms 340 KB Output is correct
24 Correct 45 ms 340 KB Output is correct
25 Correct 42 ms 332 KB Output is correct
26 Execution timed out 2093 ms 596 KB Time limit exceeded
27 Halted 0 ms 0 KB -