Submission #394163

#TimeUsernameProblemLanguageResultExecution timeMemory
394163Osama_AlkhodairyXylophone (JOI18_xylophone)C++17
100 / 100
135 ms388 KiB
#include <bits/stdc++.h> #include "xylophone.h" //~ #include "grader.cpp" using namespace std; static int A[5000]; int ask(int s, int t){ return query(s + 1, t + 1); } void solve(int n){ vector <int> a(n); a[0] = 0; a[1] = a[0] + ask(0, 1); for(int i = 0 ; i + 2 < n ; i++){ int cur = abs(a[i] - a[i + 1]); int c = ask(i, i + 2); if(c == cur){ int d = ask(i + 1, i + 2); if(a[i + 1] > a[i]){ a[i + 2] = a[i + 1] - d; } else{ a[i + 2] = a[i + 1] + d; } } else{ int d = ask(i + 1, i + 2); if(c == d){ if(a[i + 1] > a[i]){ a[i + 2] = a[i + 1] - c; } else{ a[i + 2] = a[i + 1] + c; } } else{ if(a[i] > a[i + 1]){ a[i + 2] = a[i] - c; } else{ a[i + 2] = a[i] + c; } } } } int mn = 0, mx = 0; for(int i = 0 ; i < n ; i++){ if(a[i] < a[mn]) mn = i; if(a[i] > a[mx]) mx = i; } if(mx < mn){ for(auto &i : a){ i *= -1; } } mn = 1e9; for(auto &i : a) mn = min(mn, i); for(auto &i : a) i = i - mn + 1; for(int i = 0 ; i < n ; i++){ answer(i + 1, a[i]); } }

Compilation message (stderr)

xylophone.cpp:6:12: warning: 'A' defined but not used [-Wunused-variable]
    6 | static int A[5000];
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...