#include <bits/stdc++.h>
#include "xylophone.h"
using namespace std;
#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif
#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;
namespace {
const int MXN = 10005;
int a[MXN], b[MXN];
int ans[MXN];
}
void solve(int n) {
FOR(i, 1, n) a[i] = query(i, i + 1);
FOR(i, 2, n) b[i] = query(i - 1, i + 1);
ans[1] = a[1];
bool p = 1;
FOR(i, 2, n) {
if (a[i - 1] + a[i] == b[i]) p *= -1;
ans[i] = ans[i - 1] + a[i] * p;
}
int sml = min_element(ans, ans + n) - ans, big = max_element(ans, ans + n) - ans;
if (sml > big) {
swap(sml, big);
FOR(i, 0, n) ans[i] *= -1;
}
int x = -a[sml];
FOR(i, 0, n) ans[i] += x + 1;
FOR(i, 0, n) answer(i + 1, ans[i]);
}
#ifdef MIKU
void miku() {
}
int32_t main() {
cin.tie(0) -> sync_with_stdio(false);
cin.exceptions(cin.failbit);
miku();
return 0;
}
#endif
Compilation message
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:34:40: warning: '*' in boolean context, suggest '&&' instead [-Wint-in-bool-context]
34 | if (a[i - 1] + a[i] == b[i]) p *= -1;
| ~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Incorrect |
0 ms |
444 KB |
Wrong Answer [4] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Incorrect |
0 ms |
444 KB |
Wrong Answer [4] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
440 KB |
Output is correct |
2 |
Incorrect |
0 ms |
444 KB |
Wrong Answer [4] |
3 |
Halted |
0 ms |
0 KB |
- |