Submission #516091

#TimeUsernameProblemLanguageResultExecution timeMemory
516091lovrotXylophone (JOI18_xylophone)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; vector<int> rj(n); int ask(int s, int t){ return query(s + 1, t + 1); } void solve(int n){ rj[0] = 0; rj[1] = rj[0] + ask(0, 1); for(int i = 0; i + 2 < n; i++){ int cur = abs(rj[i] - rj[i + 1]); int c = ask(i, i + 2); if(c == cur){ int d = ask(i + 1, i + 2); if(rj[i + 1] > rj[i]){ rj[i + 2] = rj[i + 1] - d; } else{ rj[i + 2] = rj[i + 1] + d; } } else{ int d = ask(i + 1, i + 2); if(c == d){ if(rj[i + 1] > rj[i]){ rj[i + 2] = rj[i + 1] - c; } else{ rj[i + 2] = rj[i + 1] + c; } } else{ if(rj[i] > rj[i + 1]){ rj[i + 2] = rj[i] - c; } else{ rj[i + 2] = rj[i] + c; } } } } int mn = 0, mx = 0; for(int i = 0 ; i < n ; i++){ if(rj[i] < rj[mn]) mn = i; if(rj[i] > rj[mx]) mx = i; } if(mx < mn){ for(int i : rj){ i *= -1; } } mn = 1e9; for(int i : rj) mn = min(mn, i); for(int i : rj) i = i - mn + 1; for(int i = 0 ; i < n ; i++){ answer(i + 1, rj[i]); } }

Compilation message (stderr)

xylophone.cpp:6:16: error: 'n' was not declared in this scope; did you mean 'yn'?
    6 | vector<int> rj(n);
      |                ^
      |                yn