Submission #939447

#TimeUsernameProblemLanguageResultExecution timeMemory
939447JakobZorzXylophone (JOI18_xylophone)C++17
100 / 100
62 ms600 KiB
#include"xylophone.h" #include<iostream> #include<vector> using namespace std; void solve(int n){ vector<int>res(n); res[0]=0; res[1]=query(1,2); int mn=0; for(int i=2;i<n;i++){ int r1=query(i,i+1); int r2=query(i-1,i+1); res[i]=res[i-1]+r1; if(max(max(res[i-2],res[i-1]),res[i])-min(min(res[i-2],res[i-1]),res[i])!=r2) res[i]=res[i-1]-r1; mn=min(mn,res[i]); } for(int&i:res) i-=mn-1; bool gotn=false; for(int i:res){ if(i==n) gotn=true; if(i==1&&gotn){ for(int&i:res) i=n-i+1; break; } } for(int i=0;i<n;i++) answer(i+1,res[i]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...