/*
in the name of god
*/
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,avx,avx2,popcnt,tune=native")
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long ,long long> pll;
typedef long long ll ;
#define File freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define all(V) V.begin(),V.end()
#define setprec(x) fixed << setprecision(x)
#define Mp(a,b) make_pair(a,b)
#define len(V) (int)(V.size())
#define sep ' '
#define endl '\n'
#define pb push_back
#define fi first
#define sec second
#define popcount(x) __builtin_popcount(x)
#define lid u<<1
#define rid (lid)|1
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 2e5 + 10,SQ=320,LOG=31;
const ll inf = 2e9 , MD = 1e9 + 7;
inline ll md(ll x){ x %= MD; return (x < 0 ? x + MD : x);}
int f[N],g[N];
int n;
int arr[N];
void solve(int nn){
n = nn;
for(int i =1 ;i < n;i++) f[i] = query(i,i+1);
for(int i =1 ;i + 2 <= n;i++){
g[i] = query(i,i+2);
}
for(int dir = -1;dir <=1;dir+=2){
arr[1] = 0;
arr[2] = f[1] * dir;
int lst = dir;
for(int j =3;j <= n;j++){
if(f[j-2] + f[j-1] != g[j-2]) lst *= -1;
arr[j] = arr[j-1] + f[j-1] * lst;
}
int mn = *min_element(arr+1,arr+n+1);
for(int i =1 ;i <= n;i++) arr[i] += (abs(mn) + 1);
int pos1=-1,posn=-1;
for(int i=1 ;i <= n;i++){
if(arr[i] == 1) pos1 = i;
if(arr[i] == n) posn = i;
}
if(pos1 <= posn){
for(int i=1 ;i <= n;i++) answer(i,arr[i]);
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |