Submission #198582

#TimeUsernameProblemLanguageResultExecution timeMemory
198582rKrPaNXylophone (JOI18_xylophone)C++98
Compilation error
0 ms0 KiB
#include "xylophone.h" #include <algorithm> static int niz[5000]; int Q[5000][2]; void solve(int N) { for (int i = 1; i <= N-1; i++){ Q[i][1] = query(i, i+1); } for (int i = 1; i <= N-2; i++){ Q[i][2] = query(i, i+2); } niz[2] = Q[1][1]; for (int i = 3; i <= N; i++){ if (Q[i-2][2] == Q[i-2][1] + Q[i-1][1]){ if (niz[i-2] < niz[i-1])niz[i] = niz[i-1] + Q[i-1][1]; else niz[i] = niz[i-1] - Q[i-1][1]; } if (Q[i-2][2] == max(Q[i-2][1], Q[i-1][1])){ if (niz[i-2] < niz[i-1])niz[i] = niz[i-1] - Q[i-1][1]; else niz[i] = niz[i-1] + Q[i-1][1]; } } int mn = 5010; int mx = -5010; int plus; int inv = 1; for (int i = 1; i <= N; i++){ if (niz[i] < mn)mn = niz[i]; if (niz[i] > mx)mx = niz[i]; } plus = -mn+1; for (int i = 1; i <= N; i++){ if (niz[i] == mn)break; if (niz[i] == mn + N-1){ inv = -1; plus = mx+1; break; } } for (int i = 1; i <= N; i++){ answer (i, inv*niz[i] + plus); } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:24:20: error: 'max' was not declared in this scope
   if (Q[i-2][2] == max(Q[i-2][1], Q[i-1][1])){
                    ^~~
xylophone.cpp:24:20: note: suggested alternative:
In file included from /usr/include/c++/7/algorithm:62:0,
                 from xylophone.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   'std::max'
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~