Submission #1127948

#TimeUsernameProblemLanguageResultExecution timeMemory
1127948vladiliusXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second void solve(int n){ int bl = 1, br = n; while (bl + 1 < br){ int m = (bl + br) / 2; if (query(1, m) == (n - 1)){ br = m; } else { bl = m + 1; } } if (query(1, bl) == (n - 1)) br = bl; int p = br; vector<int> f(n + 1); f[p] = n; if (p > 1) f[p - 1] = n - query(p - 1, p); if (p < n) f[p + 1] = n - query(p, p + 1); for (int i = p - 2; i > 0; i--){ int v = query(i, i + 2), u = query(i, i + 1); if (f[i + 1] > f[i + 2]){ f[i] = (v == (f[i + 1] + u - f[i + 2])) ? (f[i + 1] + u) : (f[i + 1] - u); } else { f[i] = (v == (f[i + 2] - f[i + 1] + u)) ? (f[i + 1] - u) : (f[i + 1] + u); } } for (int i = p + 2; i <= n; i++){ int v = query(i - 2, i), u = query(i - 1, i); if (f[i - 2] > f[i - 1]){ f[i] = (v == (f[i - 2] - f[i - 1] + u)) ? (f[i - 1] - u) : (f[i - 1] + u); } else { f[i] = (v == (f[i - 1] + u - f[i - 2])) ? (f[i - 1] + u) : (f[i - 1] - u); } } for (int i = 1; i <= n; i++){ answer(i, f[i]); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:13:13: error: 'query' was not declared in this scope
   13 |         if (query(1, m) == (n - 1)){
      |             ^~~~~
xylophone.cpp:20:9: error: 'query' was not declared in this scope
   20 |     if (query(1, bl) == (n - 1)) br = bl;
      |         ^~~~~
xylophone.cpp:26:31: error: 'query' was not declared in this scope
   26 |     if (p > 1) f[p - 1] = n - query(p - 1, p);
      |                               ^~~~~
xylophone.cpp:27:31: error: 'query' was not declared in this scope
   27 |     if (p < n) f[p + 1] = n - query(p, p + 1);
      |                               ^~~~~
xylophone.cpp:30:17: error: 'query' was not declared in this scope
   30 |         int v = query(i, i + 2), u = query(i, i + 1);
      |                 ^~~~~
xylophone.cpp:32:38: error: 'u' was not declared in this scope
   32 |             f[i] = (v == (f[i + 1] + u - f[i + 2])) ? (f[i + 1] + u) : (f[i + 1] - u);
      |                                      ^
xylophone.cpp:35:49: error: 'u' was not declared in this scope
   35 |             f[i] = (v == (f[i + 2] - f[i + 1] + u)) ? (f[i + 1] - u) : (f[i + 1] + u);
      |                                                 ^
xylophone.cpp:39:17: error: 'query' was not declared in this scope
   39 |         int v = query(i - 2, i), u = query(i - 1, i);
      |                 ^~~~~
xylophone.cpp:41:49: error: 'u' was not declared in this scope
   41 |             f[i] = (v == (f[i - 2] - f[i - 1] + u)) ? (f[i - 1] - u) : (f[i - 1] + u);
      |                                                 ^
xylophone.cpp:44:38: error: 'u' was not declared in this scope
   44 |             f[i] = (v == (f[i - 1] + u - f[i - 2])) ? (f[i - 1] + u) : (f[i - 1] - u);
      |                                      ^
xylophone.cpp:49:9: error: 'answer' was not declared in this scope
   49 |         answer(i, f[i]);
      |         ^~~~~~