Submission #587783

# Submission time Handle Problem Language Result Execution time Memory
587783 2022-07-02T11:13:57 Z SeDunion Team Contest (JOI22_team) C++17
Compilation error
0 ms 0 KB
#include<iostream>
#include<vector>
#include<set>

#define y2 asljdklakjsdlkj
#define mp make_pair

using namespace std;
using ll = long long;

const int N = 2e5 + 123;
const ll inf = 1e18 + 213;

ll ans = -inf;

struct point {
	ll x, y, z;
};

point e[N];

bool cmp(point a, point b) {
	return a.x < b.x;
}

ll y1 = -inf, z1 = -inf, y2 = -inf, z2 = -inf;

set<pair<ll,ll>>ys,zs;

void make(ll y, ll z) {
	if (y < y1 && z > z2) {
		y2 = y, z2 = z;
	}
	if (y > y1 && z < z2) {
		y1 = y, z1 = z;
	}
}

void upd(ll y, ll z) {
	ys.insert(mp(y, z));
	zs.insert(mp(z, y));
	make(y, z);
	while (ys.size() && ys.begin()->first < y) {
		ll Y = ys.begin()->first, Z = ys.begin()->second;
		//cout << Y << " " << Z << " + " << y << " " << z << endl;
		if (Z > z && y1 == -inf) {
			y1 = y, z1 = z;
			y2 = Y, z2 = Z;
		}
		make(Y, Z);
		ys.erase(ys.begin());
	}
	while (zs.size() && zs.begin()->first < z) {
		ll Z = zs.begin()->first, Y = zs.begin()->second;
		//cout << Y << " " << Z << " + " << y << " " << z << endl;
		if (y < Y && y1 == -inf) {
			y1 = Y, z1 = Z;
			y2 = y, z2 = z;
		}
		make(Y, Z);
		zs.erase(zs.begin());
	}
}

void get(ll x, ll y, ll z) {
	//cout << x << " " << y << " " << z << " f\n";
	//cout << y1 << " " << z1 << " | " << y2 << " " << z2 << " s\n";
	if (y1 > y && y1 > y2 && z2 > z && z2 > z1) {
		ans = max(ans, x + y1 + z2);
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0 ; i < n ; ++ i) {
		cin >> e[i].x >> e[i].y >> e[i].z;
	}
	sort(e, e + n, cmp);
	int j = 0;
	for (int i = 0 ; i < n ; ++ i) {
		while (j < i && e[j].x < e[i].x) {
			//cout << "add " << e[j].x << " " << e[j].y << " " << e[j].z << endl;
			upd(e[j].y, e[j].z);
			++j;
		}
		get(e[i].x, e[i].y, e[i].z);
	}
	cout << (ans > 0 ? ans : -1);
}

Compilation message

team.cpp: In function 'int main()':
team.cpp:81:2: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   81 |  sort(e, e + n, cmp);
      |  ^~~~
      |  qsort