Submission #497915

#TimeUsernameProblemLanguageResultExecution timeMemory
497915penguin133Xylophone (JOI18_xylophone)C++17
0 / 100
0 ms200 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; int ans[5005], D[5005], E[5005]; int check(int N){ for(int i=3;i<=N;i++){ ans[i] = ans[i-1] + D[i]; if(max({ans[i-2], ans[i-1], ans[i]}) - min({ans[i-2], ans[i-1], ans[i]}) != E[i])ans[i] = ans[i-1] - D[i]; } int minpos = 1, maxpos = 1; for(int i=1;i<=N;i++){ if(ans[minpos] > ans[i])minpos = i; if(ans[maxpos] < ans[i])maxpos = i; } for(int i=1;i<=N;i++)ans[i] += (2 - ans[minpos]); return (minpos < maxpos); } void solve(int N) { for(int i=2;i<=N;i++)D[i] = query(i-1, i); for(int i=3;i<=N;i++)E[i] = query(i-2, i); ans[1] = 0; ans[2] = 0 + D[2]; if(!check(N)){ ans[2] = 0 - D[2]; ans[1] = 0; int x = check(N); } for(int i=1;i<=N;i++)answer(i, ans[i]); }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:27:7: warning: unused variable 'x' [-Wunused-variable]
   27 |   int x = check(N);
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...