#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;
}
ak=query(1,2);
tab1[1]=ak;
tab2[1]=-ak;
for(int i=2;i<n;i++){
ak=query(i-2,i);
ak2=query(i-1,i);
if(tab1[i-1]>tab1[i-2]){
tab1[i]=tab1[i-1]+ak2*((ak>ak2)*2-1);
}
else{
tab1[i]=tab1[i-1]-ak2*((ak>ak2)*2-1);
}
if(tab2[i-1]>tab2[i-2]){
tab2[i]=tab2[i-1]+ak2*((ak>ak2)*2-1);
}
else{
tab2[i]=tab2[i-1]-ak2*((ak>ak2)*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]);
}
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:7:32: warning: unused variable 'ak3' [-Wunused-variable]
7 | int tab1[n],tab2[n],ak,ak2,ak3;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [1] |
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 [1] |
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 [1] |
3 |
Halted |
0 ms |
0 KB |
- |