#include <bits/stdc++.h>
using namespace std;
const int nMax=2e5+5;
long long count_triples(std::vector<int> H)
{
int n=H.size(),a[3],b[3],cand[10],cnt,p;
long long ans=0;
bool ok=1;
for(int i=0; i<n; ++i)
if(H[i]>10)
ok=0;
if(!ok)
{
for(int i=0; i<n-2; ++i)
for(int j=i+2; j<n; ++j)
{
cnt=0;
if(i+H[i]<j)
cand[++cnt]=i+H[i];
if(i+H[j]<j)
cand[++cnt]=i+H[j];
if(j-H[i]>i)
cand[++cnt]=j-H[i];
if(j-H[j]>i)
cand[++cnt]=j-H[j];
sort(cand+1,cand+cnt+1);
for(int q=1; q<=cnt; ++q)
if(q==1 || cand[q]!=cand[q-1])
{
p=cand[q];
a[0]=H[i],a[1]=H[j],a[2]=H[p];
b[0]=j-i,b[1]=p-i,b[2]=j-p;
sort(a,a+3);
sort(b,b+3);
if(a[0]==b[0] && a[1]==b[1] && a[2]==b[2])
ans++;
}
}
}
else
{
for(int i=0; i<n-2; ++i)
for(int j=i+1; j<min(i+10,n-1); ++j)
for(int p=j+1; p<min(i+11,n); ++p)
{
a[0]=H[i],a[1]=H[j],a[2]=H[p];
b[0]=j-i,b[1]=p-i,b[2]=p-j;
sort(a,a+3);
sort(b,b+3);
if(a[0]==b[0] && a[1]==b[1] && a[2]==b[2])
ans++;
}
}
return ans;
}
std::vector<int> construct_range(int M, int K)
{
std::vector<int> schema;
int cnt=0,x;
for(int i=0;i<M;++i)
{
cnt++;
if(cnt%2==1 && cnt%3==1)
x=2;
else
x=1;
schema.push_back(x);
}
return schema;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |