제출 #510222

#제출 시각아이디문제언어결과실행 시간메모리
510222nichkeXylophone (JOI18_xylophone)C++14
0 / 100
0 ms200 KiB
#include <bits/stdc++.h> using namespace std; int query(int l,int r); void answer(int a,int b); void solve(int n){ if(n==2){ answer(1,1); answer(1,2); return; } int diff[n+1][3]; for(int i=2;i<=n;i++)diff[i-1][0]=query(i-1,i); for(int i=3;i<=n;i++)diff[i-2][1]=query(i-2,i); diff[1][2]=1; for(int i=1;i+2<=n;i++){ if(diff[i][1]==diff[i][0]+diff[i+1][0])diff[i+1][2]=diff[i][2]; else diff[i+1][2]=diff[i][2]^1; } int res[n+1]; res[1]=0; for(int i=1;i+1<=n;i++)res[i+1]=res[i]+(-1+2*diff[i][2])*diff[i][0]; int mn=1,mx=1; for(int i=2;i<=n;i++){ if(res[i]<res[mn])mn=i; if(res[i]>res[mx])mx=i; } if(mn>mx)for(int i=1;i+1<=n;i++)diff[i][2]^=1; res[1]=0; for(int i=1;i+1<=n;i++)res[i+1]=res[i]+(-1+2*diff[i][2])*diff[i][0]; mn=1; for(int i=1;i<=n;i++)mn=min(mn,res[i]); for(int i=1;i<=n;i++)res[i]+=1+mn,answer(i,res[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...