Submission #1252550

#TimeUsernameProblemLanguageResultExecution timeMemory
1252550XXBabaProBerkayXylophone (JOI18_xylophone)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; void solve(int N) { vector<int> ans(N + 1), dif(N + 1); for (int i = 1; i < N; i++) dif[i] = query(i, i + 1); int l = 1, r = N - 1; while (l <= r) { int m = (l + r) / 2; if (query(m, N) == N - 1) l = m + 1; else r = m - 1; } int one = r; ans[one] = 1; ans[one + 1] = 1 + dif[one]; ans[one - 1] = 1 + dif[one - 1]; for (int i = 3; i <= N; i++) { if (ans[i]) continue; if (!ans[i - 1] || !ans[i - 2]) continue; int x = dif[i - 2]; int y = dif[i - 1]; int z = query(i - 2, i); if (ans[i - 2] < ans[i - 1]) { if (z != x + y) ans[i] = ans[i - 1] - y; else ans[i] = ans[i - 1] + y; } else { if (z != x + y) ans[i]= ans[i - 1] + y; else ans[i] = ans[i - 1] - y; } } for (int i = N - 2; i >= 1; i--) { if (ans[i]) continue; if (!ans[i + 1] || !ans[i + 2]) continue; int x = dif[i + 1]; int y = dif[i]; int z = query(i, i + 2); if (ans[i + 2] < ans[i + 1]) { if (z != x + y) ans[i] = ans[i + 1] - y; else ans[i] = ans[i + 1] + y; } else { if (z != x + y) ans[i] = ans[i + 1] + y; else ans[i] = ans[i + 1] - y; } } for (int i = 1; i <= N; i++) answer(i, ans[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:7:26: error: 'query' was not declared in this scope
    7 |                 dif[i] = query(i, i + 1);
      |                          ^~~~~
xylophone.cpp:14:21: error: 'query' was not declared in this scope
   14 |                 if (query(m, N) == N - 1)
      |                     ^~~~~
xylophone.cpp:31:25: error: 'query' was not declared in this scope
   31 |                 int z = query(i - 2, i);
      |                         ^~~~~
xylophone.cpp:53:25: error: 'query' was not declared in this scope
   53 |                 int z = query(i, i + 2);
      |                         ^~~~~
xylophone.cpp:68:17: error: 'answer' was not declared in this scope
   68 |                 answer(i, ans[i]);
      |                 ^~~~~~