#include<bits/stdc++.h>
#include "xylophone.h"
using namespace std;
int n, p1[5005], p2[5005], a[5005];
bool mark[50005];
void ANSWER(vector<int> &v) {
for (int i = 0; i < v.size(); i++) answer(i+1,v[i]);
}
void solve(int n) {
vector<int> ANS;
int x = query(1, 2);
for (int i = 3; i <= n; i++) {
p1[i] = query(i-1, i);
p2[i] = query(i-2, i);
}
a[1] = x;
a[2] = 0;
for (int i = 3; i <= n; i++) {
int val =a[i-1] + p1[i];
a[i] = val;
if(max({a[i], a[i-1],a[i-2]}) - min({a[i], a[i-1], a[i-2]}) == p2[i]) a[i] = val;
else a[i] = a[i-1] - p1[i];
}
int mn = n;
for (int i = 1; i <= n; i++) {
mn = min(mn, a[i]);
}
if(mn > 0) mn = -(mn-1);
else mn = abs(mn-1);
bool ac = true;
int pos1, posn;
for (int i = 1; i <= n; i++) {
a[i]+=mn;
mark[a[i]] = true;
if(a[i] > n) ac = false;
if(a[i] == 1) pos1 = i;
if(a[i] == n) posn = i;
}
for (int i = 1; i <= n; i++) if(!mark[i]) ac = false;
if(pos1 > posn) ac = false;
if(ac) {
//answer
for (int i = 1; i <= n; i++) ANS.push_back(a[i]);
answer(ANS);
}
else {
a[1] = 0, a[2] = x;
for (int i = 3; i <= n; i++) {
int val = a[i-1] + p1[i];
a[i] = val;
if(max({a[i], a[i-1],a[i-2]}) - min({a[i], a[i-1], a[i-2]}) == p2[i]) a[i] = val;
else a[i] = a[i-1] - p1[i];
}
int mn = n;
for (int i = 1; i <= n; i++) {
mn = min(mn, a[i]);
}
if(mn > 0) mn = -(mn-1);
else mn = abs(mn-1);
for (int i = 1; i <= n; i++) a[i] += mn;
for (int i = 1; i <= n; i++) ANS.push_back(a[i]);
answer(ANS);
}
}
Compilation message
xylophone.cpp: In function 'void ANSWER(std::vector<int>&)':
xylophone.cpp:10:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | for (int i = 0; i < v.size(); i++) answer(i+1,v[i]);
| ~~^~~~~~~~~~
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:49:16: error: cannot convert 'std::vector<int>' to 'int'
49 | answer(ANS);
| ^~~
| |
| std::vector<int>
In file included from xylophone.cpp:2:
xylophone.h:5:17: note: initializing argument 1 of 'void answer(int, int)'
5 | void answer(int i, int a);
| ~~~~^
xylophone.cpp:67:16: error: cannot convert 'std::vector<int>' to 'int'
67 | answer(ANS);
| ^~~
| |
| std::vector<int>
In file included from xylophone.cpp:2:
xylophone.h:5:17: note: initializing argument 1 of 'void answer(int, int)'
5 | void answer(int i, int a);
| ~~~~^