Submission #147730

#TimeUsernameProblemLanguageResultExecution timeMemory
147730mosiashvililukaXylophone (JOI18_xylophone)C++14
0 / 100
98 ms376 KiB
#include<bits/stdc++.h> #include "xylophone.h" using namespace std; int a,b,c,d,e,n,f[5009],mn; pair <int, int> p[3]; void upd(int q, int w){ if(p[1].first>=q){ p[2].first=p[1].first; p[1].first=q; p[1].second=w; }else{ if(p[2].first>q){ p[2].first=q; p[2].second=w; } } } void solve(int n){ a=query(1,2); mn=n*2; f[1]=0; f[2]=a; for(c=2; c<n; c++){ a=abs(f[c]-f[c-1]); if(f[c]>f[c-1]){ b=query(c,c+1); c=query(c-1,c+1); if(c==a+b){ f[c+1]=f[c]+b; }else{ f[c+1]=f[c]-b; } }else{ b=query(c,c+1); c=query(c-1,c+1); if(c==a+b){ f[c+1]=f[c]-b; }else{ f[c+1]=f[c]+b; } } } p[1].first=n*2; p[2].first=n*2; for(c=1; c<=n; c++){ upd(f[c],c); } if(p[1].second>p[2].second){ for(c=1; c<=n; c++) f[c]=-f[c]; } for(c=1; c<=n; c++) if(mn>f[c]) mn=f[c]; for(c=1; c<=n; c++){ answer(c,f[c]+mn+1); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...