제출 #1290820

#제출 시각아이디문제언어결과실행 시간메모리
1290820ecen303개의 봉우리 (IOI25_triples)C++20
컴파일 에러
0 ms0 KiB
//testing AI code #include <iostream> #include <vector> #include <algorithm> using namespace std; // Part I: Count mythical triples long long count_triples(const std::vector<int>& H) { int N = H.size(); long long result = 0; // Brute-force for (int i = 0; i < N; ++i) { for (int j = i+1; j < N; ++j) { for (int k = j+1; k < N; ++k) { 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; } // Part II: Construct range with many mythical triples (naive version) std::vector<int> construct_range(int M, int K) { // Example: just construct a strictly increasing sequence int N = min(M, 10); // For demonstration, use up to 10 peaks std::vector<int> H(N); for (int i = 0; i < N; ++i) H[i] = i+1; // Heights: 1,2,3,...,N return H; } // Main function to use grader format for both parts int main() { int mode; cin >> mode; if (mode == 1) { // Part I int N; cin >> N; std::vector<int> H(N); for (int i = 0; i < N; ++i) cin >> H[i]; long long ans = count_triples(H); cout << ans << endl; } else if (mode == 2) { // Part II int M, K; cin >> M >> K; std::vector<int> H = construct_range(M, K); cout << H.size(); for (int x : H) cout << " " << x; cout << endl; } return 0; }

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

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