Submission #981334

#TimeUsernameProblemLanguageResultExecution timeMemory
981334AmaarsaaXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; int a[5002], ans[5002]; int query(int l, int r) { int mx, mn; mx = mn= a[l]; for (int j = l; j <= r; j ++) mx = max(mx, a[j]), mn = min(mn, a[j]); return mx - mn; } void solve(int N) { int mid,i, s,x1, x2, p, n = N, lo, hi; lo = 1; hi = n; while (lo < hi) { mid = (lo + hi)/2; if ( query(1, mid) == n - 1) hi = mid; else lo = mid + 1; } ans[lo] = n; ans[lo - 1] = n - query(lo - 1, lo); for ( i = lo - 2; i >= 1; i --) { s = query(i, i + 1); p = query(i, i + 2); x1 = ans[i + 1] - s; x2 = ans[i + 1] + s; if ( max(x1, max(ans[i + 1], ans[i + 2])) - min(x1, min(ans[i + 1], ans[i + 2])) == p) { ans[i] = x1; } if ( max(x2, max(ans[i + 1], ans[i + 2])) - min(x2, min(ans[i + 1], ans[i + 2])) == p) { ans[i] = x2; } } ans[lo + 1] = n - query(lo, lo + 1); for ( i = lo + 2; i <= n; i ++) { s = query(i - 1, i); p = query(i - 2, i); x1 = ans[i - 1] - s; x2 = ans[i - 1] + s; if ( x1 >= 1 && x1 <= n && max(x1, max(ans[i - 1], ans[i - 2])) - min(x1, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x1; } if ( x2 >= 1 && x2 <= n && max(x2, max(ans[i - 1], ans[i - 2])) - min(x2, min(ans[i - 1], ans[i - 2])) == p) { ans[i] = x2; } } for (i = 1; i <= n; i ++) answer(i, ans[i]); } int main() { int n; cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; solve(n); }

Compilation message (stderr)

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