제출 #763086

#제출 시각아이디문제언어결과실행 시간메모리
763086NhanBeooXylophone (JOI18_xylophone)C++17
100 / 100
104 ms448 KiB
#include "xylophone.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair< int, int > ii;
typedef pair< int, ii > iii;
typedef vector< int > vi;
typedef vector< ii > vii;
typedef vector< iii > viii;
typedef vector< vi > vvi;
typedef vector< vii > vvii;
typedef vector< viii > vviii;
#define hdp 1e9+7
#define MAX LLONG_MAX
#define st first
#define nd second

const int N = 5005;
int a[N];

void solve(int n){
	a[2] = query(1, 2);
	for(int i=3; i<=n; i++){
		int x = query(i-1, i);
		int y = query(i-2, i);
		if((y != x + abs(a[i-1] - a[i-2]) and a[i-2] > a[i-1]) or (y == x + abs(a[i-1] - a[i-2]) and a[i-1] > a[i-2]))
			a[i] = a[i-1] + x;
		else 
			a[i] = a[i-1] - x;
	}
	if(min_element(a+1, a+n+1) > max_element(a+1, a+n+1))
		for(int i=1; i<=n; i++) a[i] *= -1;
	int m = *min_element(a+1, a+n+1);
	for(int i=1; i<=n; i++) answer(i, a[i]-m+1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...