#include<bits/stdc++.h>
#include "xylophone.h"
#define ll long long
#define all(v) begin(v), end(v)
#define pi pair<int, int>
#define vi vector<int>
using namespace std;
int a[5005], n;
int p1[5005], p2[5005];
bool thu(int z){
a[1] = 1e4, a[2] = a[1] + z;
int mi = min(a[1], a[2]);
for(int i = 3; i <= n; i++){
if(p2[i]==p1[i]+abs(a[i-2]-a[i-1])){
if(a[i-2]>a[i-1]){
a[i]=a[i-1]-p1[i];
}
else{
a[i]=a[i-1]+p1[i];
}
}
else if(p2[i]==max(p1[i],abs(a[i-2]-a[i-1]))){
if(a[i-2]>a[i-1]){
a[i]=a[i-1]+p1[i];
}
else{
a[i]=a[i-1]-p1[i];
}
}
else{
return false;
}
mi = min(mi, a[i]);
}
vector<bool> ch(n, false);
mi--;
for(int i = 1; i <= n; i++){
a[i] -= mi;
if(a[i] < 1 || a[i] > n) return false;
if(ch[a[i]-1]) return false;
ch[a[i]-1] = true;
}
return true;
}
void solve(int m){
n = m;
int d = query(1, 2);
for(int i = 3; i <= n; i++){
p1[i] = query(i-1, i), p2[i] = query(i-2, i);
}
for(int z = -d; z <= d; z+=2*d){
if(thu(z)){
for(int i = 1; i <= n; i++) answer(i, a[i]);
return ;
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |