Submission #1174934

#TimeUsernameProblemLanguageResultExecution timeMemory
1174934lopkusTeam Contest (JOI22_team)C++20
0 / 100
0 ms468 KiB
#include <bits/stdc++.h> using i64 = long long; using u64 = unsigned long long; using u32 = unsigned; using u128 = unsigned __int128; #define int long long void solve() { int N; std::cin >> N; std::vector<int> xx(N + 1), yy(N + 1), zz(N + 1); for(int i = 1; i <= N; i++) { std::cin >> xx[i] >> yy[i] >> zz[i]; } int tr = 0; std::vector<int> to_pr[10]; std::vector<int> w = {1, 2, 3}; auto g = [] (int u, int v) { if(u == v) { return 1; } if(u > v) { return 2; } return 0; }; do { for(int i = 0; i < 3; i++) { to_pr[tr].push_back(w[i]); } tr += 1; } while(next_permutation(w.begin(), w.end())); std::vector<int> x(N + 1), y(N + 1), z(N + 1); int ans = - 1; auto Do = [&] () { int dp[N + 1][3][3][3]; for(int i = 0; i <= N; i++) { for(int a = 0; a < 3; a++) { for(int b = 0; b < 3; b++) { for(int c = 0; c < 3; c++) { dp[i][a][b][c] = 0; } } } } /** 0 - smaller 1 - equal 2 - greater **/ for(int i = 1; i <= N; i++) { for(int j = i - 1; j >= 1; j--) { if(x[i] > x[j] && y[i] < y[j] && z[i] <= z[j]) { ans = std::max(ans, dp[j][0][2][0] + x[i] + y[j]); ans = std::max(ans, dp[j][1][2][0] + x[i] + y[j]); } } for(int j = i - 1; j >= 1; j--) { dp[i][g(x[i], x[j])][g(y[i], y[j])][g(z[i], z[j])] = std::max(dp[i][g(x[i], x[j])][g(y[i], y[j])][g(z[i], z[j])], z[j]); } } }; for(int i = 0; i < 6; i++) { if(to_pr[i][0] == 1) { for(int j = 1; j <= N; j++) { x[j] = xx[j]; } } if(to_pr[i][0] == 2) { for(int j = 1; j <= N; j++) { x[j] = yy[j]; } } if(to_pr[i][0] == 3) { for(int j = 1; j <= N; j++) { x[j] = zz[j]; } } if(to_pr[i][1] == 1) { for(int j = 1; j <= N; j++) { y[j] = xx[j]; } } if(to_pr[i][1] == 2) { for(int j = 1; j <= N; j++) { y[j] = yy[j]; } } if(to_pr[i][1] == 3) { for(int j = 1; j <= N; j++) { y[j] = zz[j]; } } if(to_pr[i][2] == 1) { for(int j = 1; j <= N; j++) { z[j] = xx[j]; } } if(to_pr[i][2] == 2) { for(int j = 1; j <= N; j++) { z[j] = yy[j]; } } if(to_pr[i][2] == 3) { for(int j = 1; j <= N; j++) { z[j] = zz[j]; } } for(int C = 0; C < 2; C++, reverse(x.begin() + 1, x.end()), reverse(y.begin() + 1, y.end()), reverse(z.begin() + 1, z.end())) { Do(); } } std::cout << ans; } signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t = 1; //std::cin >> t; while (t--) { solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...