제출 #1253213

#제출 시각아이디문제언어결과실행 시간메모리
1253213thdh__Team Contest (JOI22_team)C++20
100 / 100
121 ms14752 KiB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define eb emplace_back
#define pu push
#define ins insert
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define bruh ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fu(x,a,b) for (auto x=a;x<=b;x++)
#define fd(x,a,b) for (auto x=a;x>=b;x--)
#define int ll

using namespace std;
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

/*
Competitive Programming notes that I need to study & fix my dumbass self:

1. Coding:
- Always be sure to check the memory of arrays (maybe use vectors), for loops
- Always try to maximize the memory if possible, even if you are going for subtasks
- Do not exploit #define int long long, it will kill you

2. Stress: 
- Always try generating big testcases and try if they run

3. Time management:
- Don't overcommit or undercommit, always spend a certain amount of time to think a problem, don't just look at it and say I'm fucked
- Do not spend too much time coding brute-force solutions, they should be easily-codable solutions that don't take up too much time

Time management schedule:
Offline / LAH days (4 problems - 3h):
15' thinking of solution / idea
1. no idea: skip
2. yes idea: continue thinking for <= 15'

+ implementing: <= 20'
+ brute-force: <= 5'
+ test generator: <= 5'

I hate offline because I am dumb
*/

typedef pair<int, int> ii;
const int N = 2e5+5;
const int B = 750;
const int mod = 1e9+7;
const int inf = 1e18;
using cd = complex<double>;
const long double PI = acos(-1);
int power(int a,int b) {ll x = 1;if (a >= mod) a%=mod; while (b) {if (b & 1) x = x*a % mod;a = a*a % mod;b>>=1;}return x;} 

struct node {
	int x,y,z,id;
};

int n;
vector<node> a, b, c;
bool del[N];

bool cmp1(node x, node y) 
{
	return make_pair(x.x, x.id) < make_pair(y.x, y.id);
}

bool cmp2(node x, node y) 
{
	return make_pair(x.y, x.id) < make_pair(y.y, y.id);
}

bool cmp3(node x, node y) 
{
	return make_pair(x.z, x.id) < make_pair(y.z, y.id);
}

bool check(node x, node y, node z) 
{
	return (x.x > y.x && x.x > z.x && y.y > x.y && y.y > z.y && z.z > x.z && z.z > y.z);
}

void solve()
{
	cin>>n;
	for (int i = 0; i < n; i++) 
	{
		int x,y,z; cin>>x>>y>>z;
		a.pb({x,y,z,i});
	}
	b = a; c = a;
	sort(all(a), cmp1); sort(all(b), cmp2); sort(all(c), cmp3);
	int ia = n-1, ib = n-1, ic = n-1;
	while (ia >= 0 && ib >= 0 && ic >= 0) 
	{
		while (ia >= 0 && del[a[ia].id]) ia--;
		while (ib >= 0 && del[b[ib].id]) ib--;
		while (ic >= 0 && del[c[ic].id]) ic--;
		if (ia < 0 || ib < 0 || ic < 0) break;
		if (check(a[ia], b[ib], c[ic])) 
		{
			cout<<a[ia].x + b[ib].y + c[ic].z; return;
		} else 
		{
			if (a[ia].x <= b[ib].x) del[b[ib].id] = 1;
			else if (a[ia].x <= c[ic].x) del[c[ic].id] = 1;
			else if (b[ib].y <= a[ia].y) del[a[ia].id] = 1;
			else if (b[ib].y <= c[ic].y) del[c[ic].id] = 1;
			else if (c[ic].z <= a[ia].z) del[a[ia].id] = 1;
			else if (c[ic].z <= b[ib].z) del[b[ib].id] = 1;
		}
	}	
	cout<<-1;
}

/*
Go through the mistakes you usually make and revise your code, for god's sake...
*/

signed main()
{
	bruh
	//freopen("input.inp","r",stdin);
	//freopen("output.inp","w",stdout);
	int t = 1;
	// cin>>t;
	while (t--)
	{
		solve();
		cout<<"\n";
	}
}
#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...