Submission #516086

#TimeUsernameProblemLanguageResultExecution timeMemory
516086lovrotXylophone (JOI18_xylophone)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; int rj[5000]; 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 : a){ i *= -1; } } mn = 1e9; for(int i : a) mn = min(mn, i); for(int i : a) i = i - mn + 1; for(int i = 0 ; i < n ; i++){ answer(i + 1, rj[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:54:21: error: 'a' was not declared in this scope
   54 |         for(int i : a){
      |                     ^
xylophone.cpp:59:17: error: 'a' was not declared in this scope
   59 |     for(int i : a) mn = min(mn, i);
      |                 ^
xylophone.cpp:60:17: error: 'a' was not declared in this scope
   60 |     for(int i : a) i = i - mn + 1;
      |                 ^