# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250317 | guymmk | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "triples.h"
using namespace std;
vector<int> v
bool is_triple(vector<int>g){
vector<int>a,b;
a={g[1]-g[0],g[2]-g[0],g[2]-g[1]};
b={v[g[0]],v[g[1]],v[g[2]]};
sort(a.begin(),a.end());
sort(b.begin(),b.end());
return a==b;
}
long long count_triples(vector<int> hsh) {
v=hsh;
int ans=0;
int n=v.size();
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
for(int k=j+1;k<n;k++){vector<int>h={i,j,k};
ans+=(int)is_triple(h);
}
}
}return ans;
}
vector<int> construct_range(int M, int K) {
return {1, 1, 1};
}