Submission #1287037

#TimeUsernameProblemLanguageResultExecution timeMemory
1287037ecen30Triple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//Testing AI code
#include <vector>
#include <algorithm>
#include <iostream>

// Function to count the mythical triples
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() {
    // Input the height array (Example: you can modify it as needed)
    std::vector<int> H = {4, 1, 4, 3, 2, 6, 1};

    // Part I - Count mythical triples
    long long result = count_triples(H);

    // Output the number of mythical triples
    std::cout << result << std::endl;

    return 0;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccMgqEKq.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc0DkW97.o:triples.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccMgqEKq.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