Submission #567783

# Submission time Handle Problem Language Result Execution time Memory
567783 2022-05-24T07:51:07 Z maomao90 Team Contest (JOI22_team) C++17
8 / 100
2000 ms 2052 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<ii> 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};
	}
	sort(xyz, xyz + n, [&] (iii l, iii r) {
			return get<1>(l) < get<1>(r);
			});
	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:52:6: warning: unused variable 'ptr' [-Wunused-variable]
   52 |  int ptr = 0;
      |      ^~~
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 296 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 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 77 ms 312 KB Output is correct
15 Correct 30 ms 212 KB Output is correct
16 Correct 59 ms 328 KB Output is correct
17 Correct 59 ms 316 KB Output is correct
18 Correct 59 ms 312 KB Output is correct
19 Correct 70 ms 312 KB Output is correct
20 Correct 59 ms 316 KB Output is correct
21 Correct 56 ms 312 KB Output is correct
22 Correct 43 ms 312 KB Output is correct
23 Correct 49 ms 212 KB Output is correct
24 Correct 49 ms 212 KB Output is correct
25 Correct 47 ms 316 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 296 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 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 77 ms 312 KB Output is correct
15 Correct 30 ms 212 KB Output is correct
16 Correct 59 ms 328 KB Output is correct
17 Correct 59 ms 316 KB Output is correct
18 Correct 59 ms 312 KB Output is correct
19 Correct 70 ms 312 KB Output is correct
20 Correct 59 ms 316 KB Output is correct
21 Correct 56 ms 312 KB Output is correct
22 Correct 43 ms 312 KB Output is correct
23 Correct 49 ms 212 KB Output is correct
24 Correct 49 ms 212 KB Output is correct
25 Correct 47 ms 316 KB Output is correct
26 Execution timed out 2069 ms 340 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 1 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 1 ms 212 KB Output is correct
11 Execution timed out 2088 ms 2052 KB Time limit exceeded
12 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 1 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 1 ms 212 KB Output is correct
11 Execution timed out 2088 ms 2052 KB Time limit exceeded
12 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 1 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 1 ms 212 KB Output is correct
11 Execution timed out 2088 ms 2052 KB Time limit exceeded
12 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 1 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 1 ms 212 KB Output is correct
11 Execution timed out 2088 ms 2052 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 296 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 1 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 77 ms 312 KB Output is correct
15 Correct 30 ms 212 KB Output is correct
16 Correct 59 ms 328 KB Output is correct
17 Correct 59 ms 316 KB Output is correct
18 Correct 59 ms 312 KB Output is correct
19 Correct 70 ms 312 KB Output is correct
20 Correct 59 ms 316 KB Output is correct
21 Correct 56 ms 312 KB Output is correct
22 Correct 43 ms 312 KB Output is correct
23 Correct 49 ms 212 KB Output is correct
24 Correct 49 ms 212 KB Output is correct
25 Correct 47 ms 316 KB Output is correct
26 Execution timed out 2069 ms 340 KB Time limit exceeded
27 Halted 0 ms 0 KB -