Submission #58380

#TimeUsernameProblemLanguageResultExecution timeMemory
583803zpXylophone (JOI18_xylophone)C++14
100 / 100
134 ms972 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; int A[5009],B[5009],C[5009]; void solve(int N) { int M = 1, t = 1; for(int i = 2; i <= N; i++) A[i] = query(i-1,i); for(int i = 3; i <= N; i++) B[i] = query(i-2,i); C[2] = 1; for(int i = 3; i <= N; i++){ if(B[i] == A[i] + A[i-1]) C[i] = C[i-1]; else C[i] = 1- C[i-1]; } B[1] = 0; int X = 0; for(int i = 2; i <= N; i++){ if(C[i]) B[i] = A[i] + B[i-1]; else B[i] = -A[i] + B[i-1]; X = min(X,B[i]); } int a = 0, b = 0; for(int i = 1; i <= N; i++){ B[i] -= X-1; if(B[i] == 1) a = i; if(B[i] == N) b = i; } if(a > b) for(int i = 1; i <= N; i++) B[i] = N + 1 - B[i]; for(int i = 1; i <= N; i++) answer(i, B[i]); //i i-2 i-1 }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:6:9: warning: unused variable 'M' [-Wunused-variable]
     int M = 1, t = 1;
         ^
xylophone.cpp:6:16: warning: unused variable 't' [-Wunused-variable]
     int M = 1, t = 1;
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...