Submission #1290819

#TimeUsernameProblemLanguageResultExecution timeMemory
1290819ecen30Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//testing AI code #include <vector> #include <unordered_map> #include <algorithm> long long count_triples(const std::vector<int>& H) { long long result = 0; int N = H.size(); std::unordered_map<int, std::vector<int>> positions; // Precompute for each valid height, all positions where it appears for (int idx = 0; idx < N; ++idx) positions[H[idx]].push_back(idx); // For every possible pair (i, k), try to find j in between such that // the triple satisfies the condition for (int i = 0; i < N; ++i) { for (int k = i + 2; k < N; ++k) { int d2 = k - i; // distance from i to k int h1 = H[i], h3 = H[k]; // The only possible j must be i < j < k // The distances between the three indices are: j-i, k-i, k-j // so the triple of distances (d1, d2, d3) where: // d1 = j-i // d2 = k-i // d3 = k-j = k-i - (j-i) // Thus for a given (i, k), we want to pick j so that the heights H[i], H[j], H[k] // are a permutation of (j-i, k-i, k-j) // For all possible j between i+1 and k-1 for (int j = i + 1; j < k; ++j) { std::vector<int> dists = {j - i, k - i, k - j}; std::vector<int> heights = {H[i], H[j], H[k]}; std::sort(dists.begin(), dists.end()); std::sort(heights.begin(), heights.end()); if (dists == heights) result++; } } } return result; }

Compilation message (stderr)

/usr/bin/ld: /tmp/cccmTrkh.o: in function `main':
grader.cpp:(.text.startup+0x197): undefined reference to `construct_range(int, int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x367): undefined reference to `count_triples(std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status