Submission #1290838

#TimeUsernameProblemLanguageResultExecution timeMemory
1290838ecen303개의 봉우리 (IOI25_triples)C++20
Compilation error
0 ms0 KiB
//testing AI Code #include <bits/stdc++.h> using namespace std; long long count_triples(vector<int> H) { int N = H.size(); long long ans = 0; for (int i = 0; i < N; i++) { int d = H[i]; // want H[i] = k - i int k = i + d; // implied k if (k >= N) continue; // out of bounds → not a valid triple int hk = H[k]; // Two possible choices of j: // Case 1: hk == x => x = hk => j = i + hk, H[j] must be d - hk // Case 2: hk == d-x => x = d - hk => j = i + (d-hk), H[j] must be hk // Case 1: if (hk > 0 && hk < d) { int j = i + hk; if (j > i && j < k) { if (H[j] == d - hk) ans++; } } // Case 2: int x2 = d - hk; if (x2 > 0 && x2 < d) { int j = i + x2; if (j > i && j < k) { if (H[j] == hk) ans++; } } } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int mode; cin >> mode; if (mode == 1) { // Part I int N; cin >> N; vector<int> H(N); for (int i = 0; i < N; i++) cin >> H[i]; cout << count_triples(H) << "\n"; } else { // Part II (construction) left empty intentionally } return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccNhU7EJ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc2Xo1Ub.o:triples.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccNhU7EJ.o: in function `main':
grader.cpp:(.text.startup+0x197): undefined reference to `construct_range(int, int)'
collect2: error: ld returned 1 exit status