제출 #1265317

#제출 시각아이디문제언어결과실행 시간메모리
1265317mhn_neekXylophone (JOI18_xylophone)C++20
0 / 100
0 ms436 KiB
#include "xylophone.h"
//In the name of God
#include<bits/stdc++.h>
/*MHN*/
using namespace std;
typedef long long int lli;
typedef long double ld;
typedef pair<lli,lli> pii;
typedef vector<lli> ve;
typedef vector<pii> vp;
const lli N=4e5+100;
const lli mod=1e9+7;//998244353;//1e9+9
const lli INF=1e18;
lli power(lli x,lli y){lli res = 1;x = x % mod;while(y>0){if( y & 1 ){res = (res * x) % mod;}y = y >> 1;x = (x * x)%mod;}return res;}
lli modinv(lli x){return power(x,mod-2);}
lli divide(lli x,lli y){return ((x%mod) * modinv(y))%mod;}
#define all(v) v.begin(),v.end()
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define migmig ios_base::sync_with_stdio(false),cout.tie(0), cin.tie(0);
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define debug(x) cerr << (#x) << " " << (x) << endl
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define SUM(v) accumulate(v.begin(),v.end(), 0LL)
#define FOR(x,n) for(lli x = 0; x < n; x++)
#define FORS(x,n) for(lli x = 1; x <= n; x++)
#define TEST int TQPWIEJR; cin>>TQPWIEJR;while(TQPWIEJR--)
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define sep " "
lli A[N];
lli pos[N];
void solve(int n) {
	lli p1 = 1,p2 = n;
	while(p1 < p2){
		if(query(p1+1,p2)==n-1)p1++;
		else if(query(p1,p2-1)==n-1)p2--;
		else{
			pos[n] = p2;
			pos[1] = p1;
			A[p1] = 1;
			A[p2] = n;
			break;
		}
	}
	lli q = 0;
	for(lli i = p1-1; i > 0; i --){
		lli p = query(i,p1);
		if(p > q)A[i] = p+1;
		else{
			p = query(i,i+1);
			A[i] = A[i+1] - p;
		}
		q = p;
	}
	q = 0;
	for(lli i = p1+1; i < p2;i ++){
		lli p = query(p1,i);
		if(p > q)A[i] = p+1;
		else{
			p = query(i-1,i);
			A[i] = A[i-1] - p;
		}
		q = p;
		
	}
	q = 0;
	for(lli i = p2+1;i <= n;i ++){
		lli p = query(p2,i);
		if(p > q)A[i] = n-p;
		else{
			p = query(i-1,i);
			A[i] = A[i-1] + p;
		}
		q = p;
	}
	FORS(i,n)answer(i,A[i]);

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...