| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1287035 | ecen30 | Triple Peaks (IOI25_triples) | C++20 | 0 ms | 0 KiB |
//This is ChatGPT code. I am using this website to test different AI's and their abilities to solve IOI problems. Please understand. I do not mean to cheat. Just trying to get a good grade on my science project.
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
long long count_triples(std::vector<int>& H) {
int N = H.size();
long long mythical_triples = 0;
// Iterate over all triplets (i, j, k)
for (int i = 0; i < N - 2; ++i) {
for (int j = i + 1; j < N - 1; ++j) {
for (int k = j + 1; k < N; ++k) {
// Calculate pairwise distances
std::vector<int> distances = { j - i, k - i, k - j };
std::vector<int> heights = { H[i], H[j], H[k] };
// Sort both distances and heights
std::sort(distances.begin(), distances.end());
std::sort(heights.begin(), heights.end());
// If they match, it's a mythical triple
if (distances == heights) {
mythical_triples++;
}
}
}
}
return mythical_triples;
}
int main() {
std::vector<int> H = {4, 1, 4, 3, 2, 6, 1};
std::cout << "Mythical Triples: " << count_triples(H) << std::endl;
return 0;
}
