# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
763663 | 2023-06-22T15:13:42 Z | vjudge1 | Xylophone (JOI18_xylophone) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> #include "xylophone.h" using namespace std; #define ll long long const ll maxn = 2e5 + 69; ll ans[maxn],p[maxn],trio[maxn]; ll minn,maxx; void solve(ll n){ for(int i = 1;i<n;i++){ p[i] = query(i,i+1); } for(int i = 1;i<n-1;i++){ trio[i] = query(i,i+2); } ans[1] = 0; ans[2] = p[1]; for(int i = 3;i<=n;i++){ if(p[i-1] + p[i-2] == trio[i-2]){ if(ans[i-1] > ans[i-2]){ ans[i] = ans[i-1] + p[i-1]; }else{ ans[i] = ans[i-1] - p[i-1]; } }else{ if(ans[i-1] < ans[i-2]){ ans[i] = ans[i-1] + p[i-1]; }else{ ans[i] = ans[i-1] - p[i-1]; } } } minn = 1,maxx = 1; for(int i = 1;i<=n;i++){ if(a[i] < a[minn]){ minn = i; } if(a[i] > a[maxx]){ maxx = i; } } ll temp = a[minn]; for(int i = 1;i<=n;i++){ a[i] = a[i] - temp + 1; } if(minn > maxx){ for(int i = i<=n;i++){ a[i] = n - a[i] + 1; } } for(int i = 1;i<=n;i++) answer(i,a[i]); }