Submission #987915

# Submission time Handle Problem Language Result Execution time Memory
987915 2024-05-23T19:11:49 Z Antekb Team Contest (JOI22_team) C++17
26 / 100
555 ms 14928 KB
#include<bits/stdc++.h>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimize("trapv")
 
#define st first
#define nd second
#define pb push_back
#define eb emplace_back
#define pp(x) pop_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) (x).begin(), (x).end()
#define rev(x) reverse(all(x))
#define sor(x) sort(all(x))
#define sz(x) (int)(x).size()
#define rsz(x) resize(x)
 
using namespace std;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~~
 
template <typename H, typename T> 
ostream& operator<<(ostream& os, pair<H, T> m){
	return os <<"("<< m.st<<", "<<m.nd<<")";
}
template <typename H> 
ostream& operator<<(ostream& os, vector<H> V){
	os<<"{";
	for(int i=0; i<V.size(); i++){
		if(i)os<<" ";
		os<<V[i];
	}
	os<<"}";
	return os;
}
 
void debug(){cerr<<"\n";}
template <typename H, typename... T>
void debug(H h, T... t) {cerr<<h; if (sizeof...(t)) cerr << ", "; debug(t...);}
#define deb(x...) cerr<<#x<<" = ";debug(x);
//#define deb(x...) ;
 
///~~~~~~~~~~~~~~~~~~~~~~~~~
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii > vii;
typedef vector<ll> vl;
typedef vector<pll> vll;
typedef string str;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

 
#define BOOST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const int N=1<<20, INF=1e9+5, mod2=1e9+7, mod=998244353;

struct modint{
	int n=0;
	modint(){}
	modint(ll x){
		n=x%mod;
		if(n<0)n+=mod;
	}
	operator int(){
		return n;
	}
	modint operator+(modint a){a.n = n+a.n; if(a.n>=mod)a.n-=mod;return a;}
	modint operator+=(modint a){return (*this)=(*this)+a;}
	modint operator-(modint a){a.n = n-a.n; if(a.n<0)a.n+=mod;return a;}
	modint operator-=(modint a){return (*this)=(*this)-a;}
	modint operator*(modint a){a.n = (n*1ll*a.n)%mod; return a;}
	modint operator*=(modint a){return (*this)=(*this)*a;}
	modint por(const ll &m)const{
		modint a(1);
		if(m==0)return a;
		if(m==1)return (*this);
		a=por(m/2);
		a*=a;
		return a*(por(m&1));
	}
	modint odw(){
		return por((ll)mod-2);
	}
	modint operator/(modint a){return (*this)*a.odw();}
	modint operator/=(modint a){return (*this)=(*this)/a;}
	bool operator==(modint a){return a.n==n;}
	friend ostream& operator<<(ostream& os, modint m) {
		return os << m.n; 
	}
};
modint fact[N], fact2[N];
typedef vector<modint> vm;
void factinit(){
    fact[0]=1;
    for(int i=1; i<N; i++){
        fact[i]=(fact[i-1]*modint(i))%mod;
    }
    fact2[N-1]=fact[N-1].odw();
    for(int i=N-2; i>=0; i--){
    	fact2[i]=(fact2[i+1]*modint(i+1))%mod;
    }
}
modint npok(int _n, int _k){
    return fact[_n]*fact2[_k]*fact2[_n-_k];
}
int X[N], Y[N], Z[N];
vi Vx, Vy, Vz;
int solve(vi &typ){
	int n=typ.size();
	int a=n-1, b=n-1, c=n-1;
	while(a>=0 && typ[Vx[a]]!=0)a--;
	while(b>=0 && typ[Vy[b]]!=1)b--;
	while(c>=0 && typ[Vz[c]]!=2)c--;
	while(a>=0 && b>=0 && c>=0){
		bool to_break=1;
		while(a>=0 && (typ[Vx[a]]!=0  || Y[Vx[a]]>=Y[Vy[b]] || Z[Vx[a]]>=Z[Vz[c]]))a--, to_break=0;
		if(a==-1)break;
		while(b>=0 && (typ[Vy[b]]!=1  || X[Vy[b]]>=X[Vx[a]] || Z[Vy[b]]>=Z[Vz[c]]))b--, to_break=0;
		if(b==-1)break;
		while(c>=0 && (typ[Vz[c]]!=2  || Y[Vz[c]]>=Y[Vy[b]] || X[Vz[c]]>=X[Vx[a]]))c--, to_break=0;
		if(c==-1)break;
		if(to_break)break;	
	}
	if(a>=0 && b>=0 && c>=0)return X[Vx[a]]+Y[Vy[b]]+Z[Vz[c]];
	return -1;
}
int main(){
	//factinit();
	BOOST;
	int n;
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>X[i]>>Y[i]>>Z[i];
	}
	
	Vx.resize(n);
	iota(all(Vx), 0);
	Vy.resize(n);
	iota(all(Vy), 0);
	Vz.resize(n);
	iota(all(Vz), 0);
	sort(all(Vx), [](int a ,int b){return X[a]<X[b];});
	sort(all(Vy), [](int a ,int b){return Y[a]<Y[b];});
	sort(all(Vz), [](int a ,int b){return Z[a]<Z[b];});
	int ans=-1;
	vi typ(n);
	for(int i=0; i<200; i++){
		if(i%10==0){
			for(int &j:typ)j=rng()%3;
		}
		else{
			for(int j=n-1; j>=0 && j>=n-1000; j--){
				typ[Vx[j]]=rng()%3;
				typ[Vy[j]]=rng()%3;
				typ[Vz[j]]=rng()%3;
			}
		}
		ans=max(ans, solve(typ));
	}
	cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Correct 7 ms 8640 KB Output is correct
3 Correct 6 ms 8536 KB Output is correct
4 Correct 8 ms 8540 KB Output is correct
5 Correct 7 ms 8540 KB Output is correct
6 Correct 7 ms 8540 KB Output is correct
7 Correct 7 ms 10332 KB Output is correct
8 Correct 6 ms 8540 KB Output is correct
9 Correct 6 ms 8540 KB Output is correct
10 Correct 6 ms 8540 KB Output is correct
11 Correct 7 ms 8536 KB Output is correct
12 Correct 7 ms 10332 KB Output is correct
13 Correct 8 ms 8540 KB Output is correct
14 Correct 9 ms 8540 KB Output is correct
15 Correct 8 ms 8540 KB Output is correct
16 Correct 8 ms 8612 KB Output is correct
17 Correct 9 ms 8540 KB Output is correct
18 Correct 9 ms 10332 KB Output is correct
19 Correct 8 ms 8540 KB Output is correct
20 Correct 9 ms 8540 KB Output is correct
21 Correct 8 ms 8696 KB Output is correct
22 Correct 9 ms 8540 KB Output is correct
23 Correct 8 ms 8536 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 9 ms 8540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Correct 7 ms 8640 KB Output is correct
3 Correct 6 ms 8536 KB Output is correct
4 Correct 8 ms 8540 KB Output is correct
5 Correct 7 ms 8540 KB Output is correct
6 Correct 7 ms 8540 KB Output is correct
7 Correct 7 ms 10332 KB Output is correct
8 Correct 6 ms 8540 KB Output is correct
9 Correct 6 ms 8540 KB Output is correct
10 Correct 6 ms 8540 KB Output is correct
11 Correct 7 ms 8536 KB Output is correct
12 Correct 7 ms 10332 KB Output is correct
13 Correct 8 ms 8540 KB Output is correct
14 Correct 9 ms 8540 KB Output is correct
15 Correct 8 ms 8540 KB Output is correct
16 Correct 8 ms 8612 KB Output is correct
17 Correct 9 ms 8540 KB Output is correct
18 Correct 9 ms 10332 KB Output is correct
19 Correct 8 ms 8540 KB Output is correct
20 Correct 9 ms 8540 KB Output is correct
21 Correct 8 ms 8696 KB Output is correct
22 Correct 9 ms 8540 KB Output is correct
23 Correct 8 ms 8536 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 9 ms 8540 KB Output is correct
26 Correct 13 ms 8796 KB Output is correct
27 Correct 16 ms 8796 KB Output is correct
28 Correct 18 ms 8800 KB Output is correct
29 Correct 28 ms 8776 KB Output is correct
30 Correct 18 ms 8644 KB Output is correct
31 Correct 15 ms 8684 KB Output is correct
32 Correct 23 ms 10588 KB Output is correct
33 Correct 16 ms 8796 KB Output is correct
34 Correct 23 ms 8788 KB Output is correct
35 Correct 13 ms 8540 KB Output is correct
36 Correct 14 ms 8540 KB Output is correct
37 Correct 23 ms 8796 KB Output is correct
38 Incorrect 24 ms 8796 KB Output isn't correct
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8540 KB Output is correct
2 Correct 8 ms 8540 KB Output is correct
3 Correct 7 ms 8636 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8680 KB Output is correct
6 Correct 7 ms 8544 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 7 ms 8540 KB Output is correct
9 Correct 8 ms 8540 KB Output is correct
10 Correct 7 ms 10328 KB Output is correct
11 Correct 73 ms 12884 KB Output is correct
12 Correct 278 ms 11436 KB Output is correct
13 Correct 184 ms 12072 KB Output is correct
14 Correct 368 ms 14928 KB Output is correct
15 Correct 247 ms 12800 KB Output is correct
16 Correct 206 ms 12992 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8540 KB Output is correct
2 Correct 8 ms 8540 KB Output is correct
3 Correct 7 ms 8636 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8680 KB Output is correct
6 Correct 7 ms 8544 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 7 ms 8540 KB Output is correct
9 Correct 8 ms 8540 KB Output is correct
10 Correct 7 ms 10328 KB Output is correct
11 Correct 73 ms 12884 KB Output is correct
12 Correct 278 ms 11436 KB Output is correct
13 Correct 184 ms 12072 KB Output is correct
14 Correct 368 ms 14928 KB Output is correct
15 Correct 247 ms 12800 KB Output is correct
16 Correct 206 ms 12992 KB Output is correct
17 Correct 6 ms 8540 KB Output is correct
18 Correct 7 ms 8540 KB Output is correct
19 Correct 7 ms 8536 KB Output is correct
20 Correct 9 ms 10328 KB Output is correct
21 Correct 14 ms 8540 KB Output is correct
22 Correct 75 ms 12632 KB Output is correct
23 Correct 174 ms 12884 KB Output is correct
24 Correct 321 ms 11612 KB Output is correct
25 Correct 555 ms 12800 KB Output is correct
26 Correct 231 ms 12624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8540 KB Output is correct
2 Correct 8 ms 8540 KB Output is correct
3 Correct 7 ms 8636 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8680 KB Output is correct
6 Correct 7 ms 8544 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 7 ms 8540 KB Output is correct
9 Correct 8 ms 8540 KB Output is correct
10 Correct 7 ms 10328 KB Output is correct
11 Correct 73 ms 12884 KB Output is correct
12 Correct 278 ms 11436 KB Output is correct
13 Correct 184 ms 12072 KB Output is correct
14 Correct 368 ms 14928 KB Output is correct
15 Correct 247 ms 12800 KB Output is correct
16 Correct 206 ms 12992 KB Output is correct
17 Correct 6 ms 8540 KB Output is correct
18 Correct 7 ms 8540 KB Output is correct
19 Correct 7 ms 8536 KB Output is correct
20 Correct 9 ms 10328 KB Output is correct
21 Correct 14 ms 8540 KB Output is correct
22 Correct 75 ms 12632 KB Output is correct
23 Correct 174 ms 12884 KB Output is correct
24 Correct 321 ms 11612 KB Output is correct
25 Correct 555 ms 12800 KB Output is correct
26 Correct 231 ms 12624 KB Output is correct
27 Correct 7 ms 8540 KB Output is correct
28 Correct 8 ms 8540 KB Output is correct
29 Correct 9 ms 8540 KB Output is correct
30 Correct 9 ms 8540 KB Output is correct
31 Correct 25 ms 8792 KB Output is correct
32 Correct 14 ms 8540 KB Output is correct
33 Correct 13 ms 8540 KB Output is correct
34 Correct 81 ms 12824 KB Output is correct
35 Correct 255 ms 12624 KB Output is correct
36 Incorrect 296 ms 12724 KB Output isn't correct
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 8540 KB Output is correct
2 Correct 8 ms 8540 KB Output is correct
3 Correct 7 ms 8636 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8680 KB Output is correct
6 Correct 7 ms 8544 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 7 ms 8540 KB Output is correct
9 Correct 8 ms 8540 KB Output is correct
10 Correct 7 ms 10328 KB Output is correct
11 Correct 73 ms 12884 KB Output is correct
12 Correct 278 ms 11436 KB Output is correct
13 Correct 184 ms 12072 KB Output is correct
14 Correct 368 ms 14928 KB Output is correct
15 Correct 247 ms 12800 KB Output is correct
16 Correct 206 ms 12992 KB Output is correct
17 Correct 6 ms 8540 KB Output is correct
18 Correct 7 ms 8540 KB Output is correct
19 Correct 7 ms 8536 KB Output is correct
20 Correct 9 ms 10328 KB Output is correct
21 Correct 14 ms 8540 KB Output is correct
22 Correct 75 ms 12632 KB Output is correct
23 Correct 174 ms 12884 KB Output is correct
24 Correct 321 ms 11612 KB Output is correct
25 Correct 555 ms 12800 KB Output is correct
26 Correct 231 ms 12624 KB Output is correct
27 Correct 7 ms 8540 KB Output is correct
28 Correct 8 ms 8540 KB Output is correct
29 Correct 9 ms 8540 KB Output is correct
30 Correct 9 ms 8540 KB Output is correct
31 Correct 25 ms 8792 KB Output is correct
32 Correct 14 ms 8540 KB Output is correct
33 Correct 13 ms 8540 KB Output is correct
34 Correct 81 ms 12824 KB Output is correct
35 Correct 255 ms 12624 KB Output is correct
36 Incorrect 296 ms 12724 KB Output isn't correct
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 8540 KB Output is correct
2 Correct 7 ms 8640 KB Output is correct
3 Correct 6 ms 8536 KB Output is correct
4 Correct 8 ms 8540 KB Output is correct
5 Correct 7 ms 8540 KB Output is correct
6 Correct 7 ms 8540 KB Output is correct
7 Correct 7 ms 10332 KB Output is correct
8 Correct 6 ms 8540 KB Output is correct
9 Correct 6 ms 8540 KB Output is correct
10 Correct 6 ms 8540 KB Output is correct
11 Correct 7 ms 8536 KB Output is correct
12 Correct 7 ms 10332 KB Output is correct
13 Correct 8 ms 8540 KB Output is correct
14 Correct 9 ms 8540 KB Output is correct
15 Correct 8 ms 8540 KB Output is correct
16 Correct 8 ms 8612 KB Output is correct
17 Correct 9 ms 8540 KB Output is correct
18 Correct 9 ms 10332 KB Output is correct
19 Correct 8 ms 8540 KB Output is correct
20 Correct 9 ms 8540 KB Output is correct
21 Correct 8 ms 8696 KB Output is correct
22 Correct 9 ms 8540 KB Output is correct
23 Correct 8 ms 8536 KB Output is correct
24 Correct 10 ms 8568 KB Output is correct
25 Correct 9 ms 8540 KB Output is correct
26 Correct 13 ms 8796 KB Output is correct
27 Correct 16 ms 8796 KB Output is correct
28 Correct 18 ms 8800 KB Output is correct
29 Correct 28 ms 8776 KB Output is correct
30 Correct 18 ms 8644 KB Output is correct
31 Correct 15 ms 8684 KB Output is correct
32 Correct 23 ms 10588 KB Output is correct
33 Correct 16 ms 8796 KB Output is correct
34 Correct 23 ms 8788 KB Output is correct
35 Correct 13 ms 8540 KB Output is correct
36 Correct 14 ms 8540 KB Output is correct
37 Correct 23 ms 8796 KB Output is correct
38 Incorrect 24 ms 8796 KB Output isn't correct
39 Halted 0 ms 0 KB -