Submission #918996

#TimeUsernameProblemLanguageResultExecution timeMemory
918996viwlesxqXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; //#include "xylophone.h" #include "grader.cpp" void solve(int n) { vector<int> a(n + 1), d(n + 1); for (int i = 1; i < n; ++i) { d[i] = query(i, i + 1); } int min = 1, hi = n; while (min + 1 < hi) { int mid = (min + hi) / 2; if ((mid + 1 < n ? query(mid, n) : d[mid]) == n - 1) min = mid; else hi = mid; } a[min] = 1; int last = min, sum = 0; bool increasing = true; map<int, bool> used; used[1] = true; for (int i = min - 1; i > 0; --i) { int add = d[i]; if (increasing && (used[a[i + 1] + add] || a[i + 1] + add > n)) { increasing = false, sum = 0, last = i + 1; } else if (!increasing && (used[a[i + 1] - add] || a[i + 1] - add <= 0)) { increasing = true, sum = 0, last = i + 1; } else { int diff = (i + 1 < last ? query(i, last) : d[i]); if (sum + add != diff) { last = i + 1, sum = 0; increasing ^= true; } } a[i] = a[i + 1] + (increasing ? add : -add); used[a[i]] = true; sum += add; } last = min, sum = 0; increasing = true; for (int i = min + 1; i <= n; ++i) { int add = d[i - 1]; if (increasing && (used[a[i - 1] + add] || a[i - 1] + add > n)) { increasing = false, sum = 0, last = i - 1; } else if (!increasing && (used[a[i - 1] - add] || a[i - 1] - add <= 0)) { increasing = true, sum = 0, last = i - 1; } else { int diff = (last + 1 < i ? query(last, i) : d[last]); if (sum + add != diff) { last = i - 1, sum = 0; increasing ^= true; } } a[i] = a[i - 1] + (increasing ? add : -add); used[a[i]] = true; sum += add; } for (int i = 1; i <= n; ++i) { answer(i, a[i]); } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccv7Qf6U.o: in function `query(int, int)':
grader.cpp:(.text+0x0): multiple definition of `query(int, int)'; /tmp/ccPJlA8X.o:xylophone.cpp:(.text+0x1d0): first defined here
/usr/bin/ld: /tmp/ccv7Qf6U.o: in function `answer(int, int)':
grader.cpp:(.text+0xa0): multiple definition of `answer(int, int)'; /tmp/ccPJlA8X.o:xylophone.cpp:(.text+0x270): first defined here
/usr/bin/ld: /tmp/ccv7Qf6U.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccPJlA8X.o:xylophone.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status