#include "xylophone.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")
//#define int long long
#define pii pair<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define sp << " " <<
#define all(x) x.begin(),x.end()
#define big(x) ((int)(x.size()))
using namespace std;
const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9;
void solve(int N) {
	//eğer oryantasyon aynıysa A[1]..A[3] = A[1]...A[2]+A[2]...A[3]
	//yön değişimlerini biliom
	//2 possible çözüm var
	//ekstra contr bitiriyor
	vi A(N+1,0);
	A[1] = 0;
	int ptr = 1;
	int cur = 0;
	int dir = 1;
	for (int i=2;i<=N;i++) {
		int k = query(ptr,i);
		int d = query(i-1,i);
		if (d+cur == k) cur=k;
		else {
			ptr = i-1;
			cur = d;
			dir = -dir;
		}
		A[i] = A[i-1] +dir*d;
	}
	if (min_element(1+all(A)) > max_element(1+all(A))) {
		ptr = 1;
		A[1] = 0,cur = 0;
		dir = -1;
		for (int i=2;i<=N;i++) {
			int k = query(ptr,i);
			int d = query(i-1,i);
			if (d+cur == k) cur=k;
			else {
				ptr = i-1;
				cur = d;
				dir = -dir;
			}
			A[i] = A[i-1] +dir*d;
		}
	}
	int delt = *min_element(1+all(A));
	for (int i=1;i<=N;i++) {
		answer(i,A[i]-delt+1);
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |