제출 #892507

#제출 시각아이디문제언어결과실행 시간메모리
892507iskhakkutbilimTeam Contest (JOI22_team)C++17
100 / 100
611 ms27516 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define all(a) a.begin(), a.end() const int mod = 998244353; const int N = 2e5; struct ST{ vector<int > tree; int n; ST(int sz){ n = N; tree.resize(4 * n, -1); }; int merge(int A, int B){ return max(A, B); /*vector<int> v = {A.ff, A.ss, B.ff, B.ss}; sort(all(v)); return {v[3], v[2]}; * */ } void update(int pos, int x, int v, int vl, int vr){ if(vl == vr){ tree[v] = max(tree[v], x); }else{ int mid =(vl + vr)>>1; if(mid >= pos) update(pos, x, v<<1, vl, mid); else update(pos, x, v<<1|1, mid+1, vr); tree[v] = merge(tree[v<<1], tree[v<<1|1]); } }; int get_max(int l, int r, int v, int vl, int vr){ if(l > vr or vl > r) return -1; if(l <= vl and r >= vr) return tree[v]; int mid = (vl + vr)>>1; return merge(get_max(l, r, v<<1, vl, mid), get_max(l, r, v<<1|1, mid+1, vr)); } }; int n; int cX[N+10], cY[N+10], cZ[N+10]; void compr(auto &x, auto &y, auto &z){ vector<int> vec; for(int i = 0;i < n; i++) vec.push_back(x[i]); sort(all(vec)); vec.erase(unique(all(vec)), vec.end()); for(int i = 0;i < n; i++){ int it = lower_bound(all(vec), x[i]) - vec.begin() + 1; cX[it] = x[i]; x[i] = it; } vec.clear(); for(int i = 0;i < n; i++) vec.push_back(y[i]); sort(all(vec)); vec.erase(unique(all(vec)), vec.end()); for(int i = 0;i < n; i++){ int it = lower_bound(all(vec), y[i]) - vec.begin() + 1; cY[it] = y[i]; y[i] = it; } vec.clear(); for(int i = 0;i < n; i++) vec.push_back(z[i]); sort(all(vec)); vec.erase(unique(all(vec)), vec.end()); for(int i = 0;i < n; i++){ int it = lower_bound(all(vec), z[i]) - vec.begin() + 1; cZ[it] = z[i]; z[i] = it; } } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; vector<int> x(n), y(n), z(n); for(int i = 0;i < n; i++){ cin >> x[i] >> y[i] >> z[i]; } auto get=[&](auto x, auto y, auto z){ compr(x, y, z); vector<int> p(n); int res = -1; iota(all(p), 0); sort(all(p), [&](int i, int j){ return x[i] < x[j]; }); ST seg(N); auto chmax = [&](auto &A, auto B){ if(B.ff + B.ss > A.ff + A.ss) A = B; else if(B.ff + B.ss == A.ff + A.ss && A.ff < B.ff){ A = B; } }; for(int i : p){ //cout << x[i] << " " << y[i] << " " << z[i] << '\n'; //cout << cX[x[i]] << ' ' << cY[y[i]] << ' ' << cZ[z[i]] << '\n'; } vector<pair<int, int>> pref; for(int i : p){ // cout << cX[x[i]] << ' ' << cY[y[i]] << ' ' << cZ[z[i]] << " = "; pair<int, int> cur = {INT_MIN, INT_MIN}; if(pref.empty() == false) cur = pref.back(); int Z = seg.get_max(1, y[i]-1, 1, 1, N); if(Z > z[i]){ chmax(cur, make_pair(cY[y[i]], cZ[Z])); } pref.push_back(cur); // cout << cur.ff << ' ' << cur.ss << '\n'; seg.update(y[i], z[i], 1, 1, N); } for(int i = 0;i < n; ){ // cout << i+1 << " = "; int j = i; for(j = i; j <n && x[p[i]] == x[p[j]]; j++){ if(i == 0){ continue; } int fnY = pref[i-1].ff; int fnZ = pref[i-1].ss; if(fnY > cY[y[p[j]]] && fnZ > cZ[z[p[j]]]){ res = max(res, cX[x[p[j]]] + fnY + fnZ); } } // cout << j << '\n'; i = j; } return res; }; int ALL = -1; ALL = max(get(x, y, z), ALL); ALL = max(get(x, z, y), ALL); ALL = max(get(z, x, y), ALL); ALL = max(get(z, y, z), ALL); cout << ALL; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

team.cpp:56:12: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   56 | void compr(auto &x, auto &y, auto &z){
      |            ^~~~
team.cpp:56:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   56 | void compr(auto &x, auto &y, auto &z){
      |                     ^~~~
team.cpp:56:30: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   56 | void compr(auto &x, auto &y, auto &z){
      |                              ^~~~
team.cpp: In instantiation of 'main()::<lambda(auto:26, auto:27, auto:28)> [with auto:26 = std::vector<long long int>; auto:27 = std::vector<long long int>; auto:28 = std::vector<long long int>]':
team.cpp:152:23:   required from here
team.cpp:116:11: warning: unused variable 'i' [-Wunused-variable]
  116 |   for(int i : p){
      |           ^
#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...