| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1363878 | edga1 | Triple Peaks (IOI25_triples) | C++20 | 2095 ms | 15276 KiB |
#include <bits/stdc++.h>
#include "triples.h"
#define ll long long
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=200005;
map<array<int,3>,int> mp;
int h[N];
ll r=0,n;
void check(int p1, int p2, int p3){
if(p1>=n || p2>=n || p3>=n) return;
vector<int> d={abs(p1-p2),abs(p2-p3),abs(p1-p3)};
vector<int> ch={h[p1],h[p2],h[p3]};
vector<int> p={p1,p2,p3};
sort(d.begin(),d.end());
sort(p.begin(),p.end());
sort(ch.begin(),ch.end());
if(d[0]!=ch[0] || d[1]!=ch[1] || d[2]!=ch[2]) return;
if(mp[{p[0],p[1],p[2]}]==0){
r++;
mp[{p[0],p[1],p[2]}]=1;
}
}
long long count_triples(vector<int> H) {
n=H.size();
for(int i=0; i<n; i++) h[i]=H[i];
for(int i=0; i<n-2; i++){
mp.clear();
int d=H[i];
if(i+d>=n) continue;
int p2=i+d;
check(i,p2,p2+h[p2]);
if(p2-h[p2]>i) check(i,p2,p2-h[p2]);
if(i+h[p2]!=p2) check(i,p2,i+h[p2]);
for(int j=i+1; j+d<n; j++){
vector<int> p={i,j,j+d};
vector<int> di={j-i,j+d-i,d};
vector<int> ch={h[i],h[j],h[j+d]};
sort(di.begin(),di.end());
sort(ch.begin(),ch.end());
if(di[0]!=ch[0] || di[1]!=ch[1] || di[2]!=ch[2]) continue;
if(mp[{p[0],p[1],p[2]}]==1) continue;
r++;
}
}
return r;
}
vector<int> construct_range(int M, int K) {
return {1, 1, 1};
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
