#include "xylophone.h"
#include<bits/stdc++.h>
using namespace std;
int ans[2][5005];
int two[5005];
int three[5005];
int inf=1e9;
void solve(int N) {
int n=N;
for(int i=1;i+1<=n;i++)two[i]=query(i,i+1);
for(int i=1;i+2<=n;i++)three[i]=query(i,i+2);
int s=1;
for(int i=1;i<=n;i++){
if(i==2){
ans[0][i]=ans[0][i-1]+s*two[i-1];
ans[1][i]=ans[1][i-1]+-s*two[i-1];
}else{
if(two[i-2]+two[i-1]!=three[i-2])s*=-1;
ans[0][i]=ans[0][i-1]+s*two[i-1];
ans[1][i]=ans[1][i-1]+-s*two[i-1];
}
}
for(int i=0;i<2;i++){
pair<int,int>mn={1e9,0},mx={-1e9,0};
for(int j=1;j<=n;j++){
mn=min(mn,{ans[i][j],j});
mx=max(mx,{ans[i][j],j});
}
if(mn.second<mx.second){
int st=mn.first;
/*for(int j=1;j<=n;j++){
cerr<<ans[i][j]-st+1<<" ";
}
cerr<<"\n";*/
for(int j=1;j<=n;j++){
answer(j,ans[i][j]-st+1);
}
//cerr<<"ans done\n";
break;
}
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |