제출 #1290817

#제출 시각아이디문제언어결과실행 시간메모리
1290817ecen303개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
//testing AI Code
#include <vector>
#include <algorithm>
using namespace std;

long long count_triples(const vector<int>& H) {
    int N = (int)H.size();
    long long result = 0;

    // For all possible distances d (between peaks, must be at least 1)
    for (int d = 1; 2 * d < N; ++d) {
        // Triples: (i, i + d, i + 2d)
        for (int i = 0; i + 2 * d < N; ++i) {
            int j = i + d, k = j + d;
            int a = H[i], b = H[j], c = H[k];
            vector<int> heights = {a, b, c};
            vector<int> dists = {d, d, 2 * d};
            sort(heights.begin(), heights.end());
            sort(dists.begin(), dists.end());
            if (heights == dists)
                result++;
        }
    }

    // Now, for all possible pairs (i, k) where i < k, k-i=d1+d2,
    // j = i + d1, 1 <= d1 <= d2 < N, distinct heights: permute and check.
    // But the above loop is the dominant pattern since all distances must add up properly, so it's fast.

    return result;
}


컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccz9c852.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