Submission #1355518

#TimeUsernameProblemLanguageResultExecution timeMemory
1355518retardeTeam Contest (JOI22_team)C++20
37 / 100
2092 ms10764 KiB
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define int long long
#define all(x) (x).begin(), (x).end()

typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef map<int, int> mii;
typedef unordered_map<int, int> umii;

const int mod = 1e9 + 7;
const int inf = INTMAX_MAX;
const bool tc = false;

struct pt {
    int x, y, z;
    bool operator<(const pt & other) const {
        if (x != other.x) return x < other.x;
        if (y != other.y) return y < other.y;
        else return z < other.z;
    }
};

inline void solve() {
    int n; cin >> n;
    // pts[x] gives points
    map<int, vector<pt>> pts_temp; for (int i = 0; i < n; i++) {
        pt cur; cin >> cur.x >> cur.y >> cur.z;
        pts_temp[cur.x].pb(cur);
    }
    
    vector<pair<int, vector<pt>>> pts;
    for (auto &x : pts_temp) pts.pb(x);
    
    int ans = -1;
    map<int, vector<pt>> avail; // avail[y] gives z
    for (auto &item : pts) {
        int x = item.fi; vector<pt> s = item.se;
        // cout << "Processing X: " << x << '\n';

        for (auto &xp : s) {
            // cout << "X max point: " << xp.x << " " << xp.y << " " << xp.z << '\n';
            // process priors
            int mxz = -1;
            for (auto &item2 : avail) {
                // lesser x
                int y = item2.fi; vector<pt> s2 = item2.se;
                // cout << "Processing Y: " << y << '\n';
                for (auto &yp : s2) {
                    // cout << "Point with lower X has: " << yp.x << " " << yp.y << " " << yp.z << '\n';
                    // int z = yp.z;
                    if (mxz > max(yp.z, xp.z) && yp.y > xp.y) {
                        // this state is usable
                        ans = max(ans, x + y + mxz);
                    }
                }

                // update mxz
                for (auto &p : s2) {
                    mxz = max(mxz, p.z);
                }
            }
        }
        // cout << '\n';

        // add
        // cout << "Adding:\n";
        for (auto &p : s) {
            // these
            avail[p.y].pb(p);
            // cout << p.x << " " << p.y << " " << p.z << '\n';
        }
        // cout << '\n';
    }
    cout << ans << '\n';
}

void setIO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

signed main() {
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    //setIO();

    int t = 1;
    if (tc) {
        cin >> t;
    }

    while (t--) {
        solve();
    }
}

Compilation message (stderr)

team.cpp: In function 'void setIO(std::string)':
team.cpp:97:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   97 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
team.cpp:98:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...