Submission #763191

#TimeUsernameProblemLanguageResultExecution timeMemory
763191vjudge1Xylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include "xylophone.h" int q[5005][5005], a[5005]; void solve(int n) { for (int i = 1; i <= n-1; ++i) q[i][i+1] = q[i+1][i] = query(i, i+1); for (int i = 1; i <= n-2; ++i) q[i][i+2] = q[i+2][i] = query(i, i+2); int pos = 1; for (int i = 1<<12; i > 0; i >>= 1) { if (pos1 + i > n) break; if (query(pos + i) == n - 1) pos += i; } a[pos] = 1; if (pos < n) a[pos+1] = q[pos][pos+1] + 1; if (pos > 1) a[pos-1] = q[pos][pos-1] + 1; for (int i = pos + 2; i <= n; ++i) { if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) { if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i]; else a[i] = a[i-1] + q[i-1][i]; } else { if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i]; else a[i] = a[i-1] - q[i-1][i]; } } for (int i = pos - 2; i >= 1; --i) { if (q[i][i+1] + q[i+1][i+2] == q[i][i+2]) { if (a[i+1] < a[i+2]) a[i] = a[i+1] - q[i][i+1]; else a[i] = a[i+1] + q[i][i+1]; } else { if (a[i+1] < a[i+2]) a[i] = a[i+1] + q[i][i+1]; else a[i] = a[i+1] - q[i][i+1]; } } for (int i = 1; i <= n; ++i) answer(i, a[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:8:7: error: 'pos1' was not declared in this scope; did you mean 'pos'?
    8 |   if (pos1 + i > n) break;
      |       ^~~~
      |       pos
xylophone.cpp:9:20: error: too few arguments to function 'int query(int, int)'
    9 |   if (query(pos + i) == n - 1) pos += i;
      |                    ^
In file included from xylophone.cpp:1:
xylophone.h:4:5: note: declared here
    4 | int query(int s, int t);
      |     ^~~~~