Submission #132255

#TimeUsernameProblemLanguageResultExecution timeMemory
132255RezwanArefin01Xylophone (JOI18_xylophone)C++17
100 / 100
120 ms548 KiB
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; const int MAX = 5010; int a[MAX], d[MAX], t[MAX], dir[MAX]; void solve(int n) { for(int i = 1; i + 1 <= n; ++i) { d[i] = query(i, i + 1); } for(int i = 1; i + 2 <= n; ++i) { t[i] = query(i, i + 2); } a[1] = 1; dir[1] = 1; for(int i = 1; i < n; ++i) { if(d[i] + d[i + 1] == t[i]) { dir[i + 1] = dir[i]; } else { dir[i + 1] = -dir[i]; } a[i + 1] = a[i] + dir[i] * d[i]; } int mn = 1, mx = 1; for(int i = 1; i <= n; ++i) { if(a[i] < a[mn]) mn = i; if(a[i] > a[mx]) mx = i; } int x = a[mn]; for(int i = 1; i <= n; ++i) { a[i] = a[i] - x + 1; } if(mn > mx) { for(int i = 1; i <= n; ++i) { a[i] = n - a[i] + 1; } } for(int i = 1; i <= n; ++i) { answer(i, a[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...