제출 #701595

#제출 시각아이디문제언어결과실행 시간메모리
701595Alexabcde1Xylophone (JOI18_xylophone)C++14
0 / 100
1 ms464 KiB
#include<bits/stdc++.h> #include "xylophone.h" #define f first #define s second using namespace std; long long n,i,j,ress[5005][5005],resp,neg,minn,maxx; long long ans[5005]; long long res(long long x,long long y){ if (ress[x][y]!=0) return ress[x][y]; ress[x][y]=query(x,y); return ress[x][y]; } void solve(int n){ if (n==2){ answer(1,1); answer(2,2); return; } ans[1]=0; for (i=1;i<=n-2;i++){ if (res(i,i+1)+res(i+1,i+2)==res(i,i+2)){ ans[i+1]=ans[i]+res(i,i+1); ans[i+2]=ans[i]+res(i,i+2); if (ans[i+2]>=n){ ans[i+1]=ans[i]-res(i,i+1); ans[i+2]=ans[i]-res(i,i+2); } } else { ans[i+1]=ans[i]+res(i,i+1); ans[i+2]=ans[i+1]-res(i+1,i+2); if (ans[i+1]>=n){ ans[i+1]=ans[i]-res(i,i+1); ans[i+2]=ans[i+1]+res(i+1,i+2); } } if (ans[i+2]<0 || ans[i+1]<0) neg=1; } maxx=1; minn=1; for (i=2;i<=n;i++){ if (ans[i]>ans[maxx]) maxx=i; if (ans[i]<ans[minn]) minn=i; } if (maxx<minn) { for (i=1;i<=n;i++){ ans[i]=-ans[i]; } } minn=ans[1]; for (i=2;i<=n;i++){ minn=min(minn,ans[i]); } minn=-minn+1; for (i=1;i<=n;i++) answer(i,ans[i]+minn); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...