#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
void solve(int n){
int tab1[n],tab2[n],ak,ak2,ak3;
tab1[0]=0,tab2[0]=0;
if(n==1){
answer(1,1);
return;
}
if(n==2){
answer(1,1);
answer(2,2);
return;
}
ak2=query(1,2);
tab1[1]=ak2;
tab2[1]=-ak2;
for(int i=3;i<=n;i++){
ak3=ak2;
ak=query(i-2,i);
ak2=query(i-1,i);
if(tab1[i-1]>tab1[i-2]){
tab1[i]=tab1[i-1]+ak2*((ak>ak3)*2-1);
}
else{
tab1[i]=tab1[i-1]-ak2*((ak>ak3)*2-1);
}
if(tab2[i-1]>tab2[i-2]){
tab2[i]=tab2[i-1]+ak2*((ak>ak3)*2-1);
}
else{
tab2[i]=tab2[i-1]-ak2*((ak>ak3)*2-1);
}
}
ak=99999;
for(int i=0;i<n;i++){
ak=min(ak,tab1[i]);
}
for(int i=0;i<n;i++){
tab1[i]-=(ak-1);
}
for(int i=0;i<n;i++){
if(tab1[i]==1){
for(int j=0;j<n;j++){
answer(j,tab1[j]);
}
}
if(tab1[i]==n)
break;
}
ak=99999;
for(int i=0;i<n;i++){
ak=min(ak,tab2[i]);
}
for(int i=0;i<n;i++){
tab2[i]-=(ak-1);
}
for(int j=0;j<n;j++){
answer(j,tab2[j]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [3] |
3 |
Halted |
0 ms |
0 KB |
- |