Submission #1287042

#TimeUsernameProblemLanguageResultExecution timeMemory
1287042ecen303개의 봉우리 (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//tesing AI Code
#include <iostream>
#include <vector>
#include <algorithm>

// 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;
}

// Function to construct a mountain range that produces at least K mythical triples
std::vector<int> construct_range(int M, int K) {
    // Try to create a range with many mythical triples. We use a pattern that repeats
    // numbers in such a way to increase the likelihood of matching distances.
    std::vector<int> H;

    // Strategy: Create a simple increasing-decreasing pattern
    for (int i = 1; i <= M - 2; ++i) {
        H.push_back(i);
    }
    H.push_back(M - 1);  // The last peak at height M-1

    // For Part II, we might not know the exact number of mythical triples, but we try
    // to generate a range that has a reasonable number of them.
    return H;
}

Compilation message (stderr)

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