Submission #92795

#TimeUsernameProblemLanguageResultExecution timeMemory
92795Alexa2001Xylophone (JOI18_xylophone)C++17
0 / 100
2 ms376 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; const int Nmax = 5005; static int A[Nmax], B[Nmax], x[Nmax]; void solve(int N) { int i; for(i=1; i<=N-1; ++i) A[i] = query(i, i+1); for(i=1; i<=N-2; ++i) B[i] = query(i, i+2); x[1] = 0; x[2] = A[1]; for(i=3; i<=N; ++i) if(x[i-2] < x[i-1]) { if(B[i-2] == A[i-2]) /// middle value x[i] = x[i-1] - A[i-1]; else if(A[i-1] == B[i-2]) /// smallest value x[i] = x[i-1] - A[i-1]; else x[i] = x[i-1] + A[i-1]; /// greatest value } else { if(B[i-2] == A[i-2]) /// middle x[i] = x[i-1] + A[i-1]; else if(A[i-1] == B[i-2]) /// greatest x[i] = x[i-1] + A[i+1]; else x[i] = x[i-1] - A[i-1]; } int Min = 0; for(i=1; i<=N; ++i) Min = min(Min, x[i]); for(i=1; i<=N; ++i) x[i] -= Min - 1; int id1, idn; for(i=1; i<=N; ++i) if(x[i] == 1) id1 = i; else if(x[i] == N) idn = i; if(id1 > idn) for(i=1; i<=N; ++i) x[i] = N + 1 - x[i]; for(i=1; i<=N; ++i) answer(i, x[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:43:5: warning: 'idn' may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(id1 > idn)
     ^~
xylophone.cpp:43:5: warning: 'id1' may be used uninitialized in this function [-Wmaybe-uninitialized]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...