# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1250913 | somefolk | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <cassert>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;
#define endl "\n"
#define ll long long
const int INF = 1e9+7;
const int MOD = 1e9+7;
bool check(int d1, int d2, int d3, int h1, int h2, int h3){
return (((d1 == h1 && d2 == h2 && d3 == h3) ||
(d1 == h1 && d2 == h3 && d3 == h2) ||
(d1 == h2 && d2 == h1 && d3 == h3) ||
(d1 == h2 && d2 == h3 && d3 == h1) ||
(d1 == h3 && d2 == h1 && d3 == h2) ||
(d1 == h3 && d2 == h2 && d3 == h1)));
}
ll count_triples(vector<int> a){
int n = (int)a.size();
ll cnt = 0;
for(int i = 0; i < n; i++){
for(int j = i; j < n; j++){
for(int k = j; k < n; k++){
cnt += check(j-i, k-j, k-i, a[i], a[j], a[k]);
}
}
}
return cnt;
}