Submission #995882

#TimeUsernameProblemLanguageResultExecution timeMemory
995882khanhphucscratchXylophone (JOI18_xylophone)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "xylophone.h" #define int long long using namespace std; /*int query(int l, int r) { cout<<"? "<<l<<" "<<r<<endl; int x; cin>>x; return x; } void answer(int p, int v) { cout<<"! "<<p<<" "<<v<<endl; }*/ void solve(int n) { vector<int> a(n+1), s(n+1); a[2] = query(1, 2), s[2] = 0; int last = a[2]; for(int i = 3; i <= n; i++){ int cur = query(i-1, i), sum = query(i-2, i); a[i] = cur; if(last + cur == sum) s[i] = s[i-1]; else s[i] = (s[i-1] ^ 1); last = cur; } vector<int> cd(n+1); for(int i = 1; i <= n; i++) cd[i] = cd[i-1] + a[i] * (-s[i] * 2 + 1); int maxplace = 1, minplace = 1; for(int i = 1; i <= n; i++){ if(cd[maxplace] < cd[i]) maxplace = i; if(cd[minplace] > cd[i]) minplace = i; } if(maxplace < minplace){ for(int i = 1; i <= n; i++) s[i] ^= 1; for(int i = 1; i <= n; i++) cd[i] = cd[i-1] + a[i] * (-s[i] * 2 + 1); } int minval = 1e18; for(int i = 1; i <= n; i++) minval = min(minval, cd[i]); for(int i = 1; i <= n; i++) cd[i] += -minval + 1; for(int i = 1; i <= n; i++) answer(i, cd[i]); } /*signed main() { solve(5); }*/

Compilation message (stderr)

/usr/bin/ld: /tmp/ccdFKYEd.o: in function `main':
grader.cpp:(.text.startup+0x30): undefined reference to `solve(int)'
collect2: error: ld returned 1 exit status