//#include "triples.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
long long count_triples(vector<int> H) {
vector<int>h;
for(auto a:H)h.pb(a);
set< vector<int>>ST;
int n=H.size();
ll cnt=0;
for(int i=0;i<n;i++){
int j=h[i]+i;
int k=h[j]+j;
if(i<0 or k>n or i>j or i>k or j>k)continue;
multiset<int>st={H[i],H[j],H[k]};
if(st.find(j-i)!=st.end())st.erase(st.find(j-i));
if(st.find(k-i)!=st.end())st.erase(st.find(k-i));
if(st.find(k-j)!=st.end())st.erase(st.find(k-j));
if(st.empty()){
ST.insert({i,j,k});
}
}
for(int i=0;i<n;i++){
int j=h[i]+i;
int k=h[j]+i;
if(i<0 or k>n or i>j or i>k or j>k)continue;
multiset<int>st={H[i],H[j],H[k]};
if(st.find(j-i)!=st.end())st.erase(st.find(j-i));
if(st.find(k-i)!=st.end())st.erase(st.find(k-i));
if(st.find(k-j)!=st.end())st.erase(st.find(k-j));
if(st.empty()){
ST.insert({i,j,k});
}
}
for(int i=0;i<n;i++){
int k=h[i]+i;
int j=i+h[k];
if(i<0 or k>n or i>j or i>k or j>k)continue;
multiset<int>st={H[i],H[j],H[k]};
if(st.find(j-i)!=st.end())st.erase(st.find(j-i));
if(st.find(k-i)!=st.end())st.erase(st.find(k-i));
if(st.find(k-j)!=st.end())st.erase(st.find(k-j));
if(st.empty()){
ST.insert({i,j,k});
}
}
for(int j=1;j<n;j++){
int i=j-h[j];
int k=j+h[i];
if(i<0 or k>n or i>j or i>k or j>k)continue;
multiset<int>st={H[i],H[j],H[k]};
if(st.find(j-i)!=st.end())st.erase(st.find(j-i));
if(st.find(k-i)!=st.end())st.erase(st.find(k-i));
if(st.find(k-j)!=st.end())st.erase(st.find(k-j));
if(st.empty()){
ST.insert({i,j,k});
}
}
for(int j=1;j<n;j++){
int k=j+h[j];
int i=k-h[k];
if(i<0 or k>n or i>j or i>k or j>k)continue;
multiset<int>st={H[i],H[j],H[k]};
if(st.find(j-i)!=st.end())st.erase(st.find(j-i));
if(st.find(k-i)!=st.end())st.erase(st.find(k-i));
if(st.find(k-j)!=st.end())st.erase(st.find(k-j));
if(st.empty()){
ST.insert({i,j,k});
}
}
cnt= (ll)ST.size();
return cnt;
}
vector<int> construct_range(int M, int K) {
}
컴파일 시 표준 에러 (stderr) 메시지
triples.cpp: In function 'std::vector<int> construct_range(int, int)':
triples.cpp:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
80 | }
| ^| # | 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... |