Submission #444587

#TimeUsernameProblemLanguageResultExecution timeMemory
444587fuad27Xylophone (JOI18_xylophone)C++14
0 / 100
1 ms200 KiB
#include "xylophone.h" #include<bits/stdc++.h> using namespace std; void solve(int N) { vector<int> v(N+1, 0); int l = 0, r = N, one = N; while(l<=r) { int mid = (l+r)>>1; if(query(mid, N) == N-1 or query(mid, 1) == N - 1) { one = mid; l = mid+1; } else { r = mid - 1; } } v[one] = 1; for(int i = one + 1; i<=N;i++) { int val = query(i-1, i); if(v[i-1] + val > N) { v[i] = v[i-1] - val; } else { v[i] = v[i-1] + val; } } for(int i = one-1;i>0;i--) { int val = query(i + 1, i); if(v[i+1] + val > N) { v[i] = v[i+1] -val; } else { v[i] = v[i-1] + val; } } for(int i = 1;i<=N;i++) { answer(i, v[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...