This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include"xylophone.h"
#include<bits/stdc++.h>
using namespace std;
void solve(int n)
{
if (n == 2)
{
answer(1, 1), answer(2, 2);
return;
}
int d[5001], e[5001];
for (int i = 1; i <= n - 1; i++)
d[i] = query(i, i + 1);
for (int i = 1; i <= n - 2; i++)
e[i] = query(i, i + 2);
bool pp;
int ans[5001];
ans[1] = 1, ans[2] = ans[1] + d[1];
if (d[1] + d[2] == e[1])
ans[3] = ans[2] + d[2], pp = true;
else
ans[3] = ans[2] - d[2], pp = false;
for (int i = 4; i <= n; i++)
if (d[i - 2] + d[i - 1] == e[i - 2])
if (pp)
ans[i] = ans[i - 1] + d[i - 1];
else
ans[i] = ans[i - 1] - d[i - 1];
else
if (pp)
ans[i] = ans[i - 1] - d[i - 1], pp = false;
else
ans[i] = ans[i - 1] + d[i - 1], pp = true;
int mn = 1e9;
for (int i = 1; i <= n; i++)
mn = min(mn, ans[i]);
for (int i = 1; i <= n; i++)
ans[i] += -mn + 1;
bool ok;
for (int i = 1; i <= n; i++)
if (ans[i] == 1)
{
ok = true;
break;
}
else if (ans[i] == n)
{
ok = false;
break;
}
else;
if (!ok)
for (int i = 1; i <= n; i++)
ans[i] = n - ans[i] + 1;
for (int i = 1; i <= n; i++)
answer(i, ans[i]);
}
Compilation message (stderr)
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:59:5: warning: 'ok' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (!ok)
^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |