제출 #1293157

#제출 시각아이디문제언어결과실행 시간메모리
1293157blackscreen1Xylophone (JOI18_xylophone)C++20
100 / 100
27 ms452 KiB
#include "xylophone.h"
#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define ll long long
#define ld long double
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1))
#define iloop_(m, h, g) for (auto i = m; i < h; i += g)
#define jloop_(m, h, g) for (auto j = m; j < h; j += g)
#define kloop_(m, h, g) for (auto k = m; k < h; k += g)
#define lloop_(m, h, g) for (auto l = m; l < h; l += g)
#define getchar_unlocked _getchar_nolock // comment before submission
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define pllll pair<pll, pll>
#define vll vector<ll>
#define qll queue<ll>
#define dll deque<ll>
#define pqll priority_queue<ll>
#define gll greater<ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
void solve(int N) {
	ll n = N;
	if (n == 1) {answer(1, 1); return;}
	ll res[n], t1, t2;
	res[0] = 0;
	res[1] = query(1, 2);
	iloop(2, n) {
		t1 = query(i-1, i+1), t2 = query(i, i+1);
		if (abs(res[i-1] - res[i-2]) + t2 == t1) {
			if (res[i-1] > res[i-2]) res[i] = res[i-1] + t2;
			else res[i] = res[i-1] - t2;
		}
		else {
			if (res[i-1] > res[i-2]) res[i] = res[i-1] - t2;
			else res[i] = res[i-1] + t2;
		}
	}
	t1 = *min_element(res, res+n);
	t2 = -1;
	bool tf = 0;
	iloop(0, n) {
		res[i] += -t1 + 1;
		if (res[i] == n && t2 == -1) tf = 1;
		if (res[i] == n || res[i] == 1) t2 = 0;
	}
	if (tf) iloop(0, n) res[i] = n + 1 - res[i];
	iloop(0, n) answer(i+1, res[i]);
	
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...