Submission #1250215

#TimeUsernameProblemLanguageResultExecution timeMemory
1250215ezzzay3개의 봉우리 (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include "triples.h" #include <vector> using namespace std; // Part I: O(N) scan by anchoring on each index long long count_triples(const vector<int>& H) { int N = H.size(); long long ans = 0; // Case A: H[i] = d(i,j), H[j] = d(j,k), so j=i+H[i], k=j+H[j], and H[k]==H[i]+H[j] for(int i=0; i<N; i++){ int j = i + H[i]; if(j < N){ int k = j + H[j]; if(k < N && H[k] == H[i] + H[j]) ans++; } } // Case B: H[i] = d(i,j), H[k] = d(i,k), so k=i+H[i], j=k-H[k], and H[j]==H[i]+H[k] for(int i=0; i<N; i++){ int k = i + H[i]; if(k < N){ int j = k - H[k]; if(j > i && j < N && H[j] == H[i] + H[k]) ans++; } } // Case C: H[j] = d(j,k), H[j] = d(i,j), so i=j-H[j], k=j+H[j], and H[i]+H[k]==H[j] for(int j=0; j<N; j++){ int i = j - H[j]; int k = j + H[j]; if(i >= 0 && k < N && H[i] + H[k] == H[j]) ans++; } return ans; } // Part II: fill with 1s → every consecutive triple (i,i+1,i+2) is mythical. // You get (N-2) triples out of N peaks. vector<int> construct_range(int M, int K) { int N; if(M >= K + 2) { // can hit exactly K triples → full credit N = K + 2; } else if(M >= 3) { // use all M peaks → M-2 triples N = M; } else { // too small for any triple, just output M ones N = M; } return vector<int>(N, 1); }

Compilation message (stderr)

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