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>
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
const ll maxn = 5005;
ll T[maxn];
ll n;
ll Min = 1, Max = 2;
void solve(int x)
{
n = x;
T[1] = 0;
T[2] = query(1,2);
ll ptr = 1;
ll cur = T[2];
for(int i = 3; i<= n; i++)
{
ll value = query(i-2, i);
ll value2 = query(i-1, i);
if(value==abs(T[i-1]-T[i-2]))
{
if(T[i-2]>T[i-1]) T[i] = T[i-1]+value2;
else T[i] = T[i-1]-value2;
}
else
{
if(T[i-2]>T[i-1]) T[i] = T[i-1]-value2;
else T[i] = T[i-1]+value2;
}
}
ll Minn = 0;
for(int i = 1; i<= n; i++) Minn = min(Minn, T[i]);
for(int i = 1; i<= n; i++) T[i] += abs(Minn)+1;
ll xMin = 0, xMax = 0;
for(int i = 1; i<= n; i++)
{
if(T[i]==n) xMax = i;
if(T[i]==1) xMin = i;
}
if(xMin>xMax)
{
for(int i = 1; i<= n/2; i++) swap(T[i], T[n+1-i]);
}
//for(int i = 1; i<= n; i++) cout << T[i] << " ";
for(int i = 1; i<= n; i++)
{
answer(i, T[i]);
}
}
Compilation message (stderr)
xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:20:8: warning: unused variable 'ptr' [-Wunused-variable]
20 | ll ptr = 1;
| ^~~
xylophone.cpp:21:8: warning: unused variable 'cur' [-Wunused-variable]
21 | ll cur = T[2];
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |