Submission #1306895

#TimeUsernameProblemLanguageResultExecution timeMemory
1306895teamcuddlepieXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; // These are provided by the grader (do NOT implement them) int query(int l, int r); void answer(vector<int> A); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> d(N - 1); // 1) Adjacent differences for (int i = 0; i < N - 1; i++) { d[i] = query(i + 1, i + 2); } // sign[i] = +1 if A[i+1] > A[i], -1 otherwise vector<int> sign(N - 1); sign[0] = 1; // arbitrarily assume increasing at first // 2) Determine directions using triples for (int i = 0; i < N - 2; i++) { int t = query(i + 1, i + 3); if (t == d[i] + d[i + 1]) { // same direction sign[i + 1] = sign[i]; } else { // direction flips sign[i + 1] = -sign[i]; } } // 3) Build relative values vector<int> b(N); b[0] = 0; for (int i = 1; i < N; i++) { b[i] = b[i - 1] + sign[i - 1] * d[i - 1]; } // 4) Normalize to permutation 1..N int mn = *min_element(b.begin(), b.end()); for (int i = 0; i < N; i++) { b[i] -= mn; } // Now b contains values from 0..N-1 (in some order) vector<int> A(N); for (int i = 0; i < N; i++) { A[i] = b[i] + 1; } // Output answer answer(A); return 0; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccyDwWeo.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccOK9qIV.o:xylophone.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccOK9qIV.o: in function `main':
xylophone.cpp:(.text.startup+0x283): undefined reference to `answer(std::vector<int, std::allocator<int> >)'
/usr/bin/ld: /tmp/ccyDwWeo.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status