| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1290827 | ecen30 | 3개의 봉우리 (IOI25_triples) | C++20 | 0 ms | 0 KiB |
//testing AI Code
#include <vector>
#include <algorithm>
using namespace std;
// Counts mythical triples in given heights vector H
long long count_triples(const vector<int>& H) {
int N = (int)H.size();
long long result = 0;
// Iterate over all possible gaps a, b where a + b < N
for (int a = 1; a < N - 1; ++a) {
for (int b = 1; a + b < N; ++b) {
int c = a + b;
// For each valid starting index i where i+a+b < N
for (int i = 0; i + c < N; ++i) {
int j = i + a;
int k = i + c;
// Check if heights match distances ignoring order
vector<int> dist = {a, b, c};
vector<int> heights = {H[i], H[j], H[k]};
sort(dist.begin(), dist.end());
sort(heights.begin(), heights.end());
if (dist == heights) {
++result;
}
}
}
}
return result;
}
// Constructs a mountain range with a valid pattern (naive stub)
vector<int> construct_range(int M, int K) {
int N = min(M, 10);
vector<int> H(N);
for (int i = 0; i < N; ++i) {
H[i] = (i % (N - 1)) + 1; // Ensure heights within [1, N-1]
}
return H;
}
