#include "xylophone.h"
#include <bits/stdc++.h>
//#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define pii pair<int,int>
using namespace std;
const int MAXN = 5000+5;
const int mod7 = 1e9+7;
const long long inf = 1e18;
int querypair[MAXN];
int querytriple[MAXN];
int n;
vector<int>niz(MAXN);
bool resi(bool znak)
{
vector<int>vis(MAXN,0);
niz[1] = 0;
if(znak)niz[2] = querypair[1];
else niz[2] = -querypair[1];
for(int i=3; i<n; i++)
{
if(querypair[i-2] + querypair[i-1] == querytriple[i-2])znak = !znak;
if(znak)niz[i] = niz[i-1] + querypair[i-1];
else niz[i] = niz[i-1] - querypair[i-1];
}
int mn = *min_element(all(niz));
bool moze = true;
for(int i=1; i<=n; i++)
{
niz[i] = niz[i] -mn + 1;
if(niz[i] > 0)vis[niz[i]] = i;
}
for(int i=1; i<=n; i++)if(vis[i] == 0)moze = false;
if(vis[1] > vis[n])moze = false;
return moze;
}
void solve(int N) {
n = N;
for(int i=1; i<n; i++)querypair[i] = query(i,i+1);
for(int i=1; i<n-1; i++)querytriple[i] = query(i,i+2);
if(resi(true))for(int i=1; i<=n; i++)answer(i, niz[i]);
else
{resi(false);
for(int i=1; i<=n; i++)answer(i, niz[i]);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [7] |
3 |
Halted |
0 ms |
0 KB |
- |