Submission #1355356

#TimeUsernameProblemLanguageResultExecution timeMemory
1355356coderg300711Triple Peaks (IOI25_triples)C++20
12 / 100
2095 ms1960 KiB
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pii pair<int,int>
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define pb push_back
#define sz(x) (int)(x).size()
#define rsz resize
#define ass assign
#define F(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
//template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;
#define each(a,x) for(auto a:x)
#define FOR(i,a) for(int i=0;i<(a);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define eb emplace_back
#define ft front()
#define V vector

#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

#include "triples.h"

ll count_triples(V<int> h){
	int n=sz(h);
	ll res=0;
	FOR(i,n){
		F(j,i+1,n){
			int d1=j-i;
			F(k,j+1,n){
				int d2=k-j,d3=k-i;
				V<int> dist={d1,d2,d3};
				V<int> heights={h[i],h[j],h[k]};
				sort(dist.begin(),dist.end());
				sort(heights.begin(),heights.end());
				if(dist==heights)res++;
				if(n>2000 && d3>100)break;
			}
		}
	}
	return res;
}

int count(const V<int>& cur,int id,int h){
	int cnt=0;
	FOR(i,id){
		F(j,i+1,id){
		int d1=j-i,d2=id-j,d3=id-i;
		int h1=cur[i],h2=cur[j],h3=h;
		int mxh=max({h1,h2,h3}),mnh=min({h1,h2,h3});
		int midh=(h1+h2+h3)-mnh-mxh;
		if(mxh==d3 && mnh==min(d1,d2) && midh==max(d1,d2))cnt++;
	}
	}
	return cnt;
}

V<int> construct_range(int m,int k){
	V<int> res(m);
	FOR(i,m){
		int besth=1,mx=-1;
		int lim=(m<1000)?m:30;
		F(h,1,lim){
			int gained=count(res,i,h);
			if(gained>mx){
				mx=gained;
				besth=h;
			}
		}
		res[i]=besth;
	}
	return res; 
}
#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...
#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...