Submission #781033

#TimeUsernameProblemLanguageResultExecution timeMemory
781033Sandarach151Xylophone (JOI18_xylophone)C++17
100 / 100
101 ms352 KiB
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; void solve(int n) { // int value = query(1, N); // for(int i = 1; i <= N; i++) { // answer(i, i); // } int arr[n]; int barr[n]; int dir[n]; for(int i=0; i<n-1; i++){ arr[i]=query(i+1, i+2); } for(int i=0; i<n-2; i++){ barr[i]=query(i+1, i+3); } dir[0]=1; for(int i=0; i<n-2; i++){ if(barr[i]==max(arr[i], arr[i+1])){ dir[i+1]=-dir[i]; } else{ dir[i+1]=dir[i]; } } int ans[n]; ans[0]=0; for(int i=1; i<n; i++){ ans[i]=ans[i-1]+arr[i-1]*dir[i-1]; } int minn = 1000000; for(int i=0; i<n; i++){ minn = min(minn, ans[i]); } for(int i=0; i<n; i++){ ans[i]+=1-minn; } bool res = false; for(int i=0; i<n; i++){ if(ans[i]==n){ res = true; break; } else if(ans[i]==1){ break; } } if(res==true){ for(int i=0; i<n; i++){ ans[i] = n+1-ans[i]; } } for(int i=0; i<n; i++){ answer(i+1, ans[i]); } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...