#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
void solve(int N){
int lst[5100];
int q[5100];
vector<int> v;
int en = 1;
for(int i = N - 1; i >= 1; i--){
if(query(1,i) != N - 1){
en = i + 1;
}
}
int l = en;
lst[en] = N;
q[en] = 0;
if(en != 1){
lst[en - 1] = N - query(en - 1, en);
}
for(int i = en - 2; i > 0; i--){
int v = query(i,i + 1);
q[i] = query(i,i + 2);
if(lst[i + 1] < lst[i + 2]){
if(q[i] == lst[i + 2] - lst[i + 1] + v){
lst[i] = lst[i + 1] - v;
}
else{
lst[i] = lst[i + 1] + v;
}
}
else{
if(q[i] == lst[i + 1] - lst[i + 2] + v){
lst[i] = lst[i + 1] + v;
}
else{
lst[i] = lst[i + 1] - v;
}
}
}
if(en != N){
lst[en + 1] = N - query(en, en + 1);
}
for(int i = en + 1; i <= N; i++){
int v = query(i - 1,i);
q[i] = query(i - 2,i);
if(lst[i - 1] < lst[i - 2]){
if(q[i] == lst[i - 2] - lst[i - 1] + v){
lst[i] = lst[i - 1] - v;
}
else{
lst[i] = lst[i - 1] + v;
}
}
else{
if(q[i] == lst[i - 1] - lst[i - 2] + v){
lst[i] = lst[i - 1] + v;
}
else{
lst[i] = lst[i - 1] - v;
}
}
}
for(int i = 1; i <= N; i++){
answer(i,lst[i]);
}
}
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:19:9: warning: unused variable 'l' [-Wunused-variable]
19 | int l = en;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Incorrect |
2 ms |
208 KB |
Wrong Answer [7] |
4 |
Halted |
0 ms |
0 KB |
- |