제출 #763323

#제출 시각아이디문제언어결과실행 시간메모리
763323vjudge1Xylophone (JOI18_xylophone)C++17
0 / 100
1 ms208 KiB
#include "xylophone.h" #include <bits/stdc++.h> using namespace std; #define ll long long void solve(int N){ cin>>N; vector<int> duo(N+1,0); vector<int> trio(N+1,0); vector<int> arr(N+1,0); for(int i=1;i<N;++i){ duo[i-1] = query(i,i+1); } arr[1] = duo[0]; for(int i=2;i<N;++i){ trio[i-2] = query(i-1,i+1); } bool greater = true; for(int i=2;i<N;++i){ if(trio[i-2] != duo[i-1] + duo[i-2]){ greater = !greater; } arr[i] = arr[i-1] + duo[i-1] * ((int)greater * 2 - 1); } int maxi = 0, mini = 0; int maxpos = 0, minpos = 0; for(int i=1;i<N;++i){ if(arr[i] > maxi){ maxi = arr[i]; maxpos = i; } if(arr[i] < mini){ mini = arr[i]; minpos = i; } } if(minpos < maxpos){ for(int i=0;i<N;++i){ answer(i+1,arr[i]-mini + 1); } } else{ for(int i=0;i<N;++i){ answer(i+1,maxi - arr[i] + 1); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...