QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#289091#7859. Bladestormucup-team087#AC ✓886ms19184kbC++2024.8kb2023-12-23 15:18:012023-12-23 15:18:01

Judging History

你现在查看的是最新测评结果

  • [2023-12-23 15:18:01]
  • 评测
  • 测评结果:AC
  • 用时:886ms
  • 内存:19184kb
  • [2023-12-23 15:18:01]
  • 提交

answer

#ifndef LOCAL
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#endif

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
//#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define si(x) int(x.size())
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.a<<","<<p.b<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

#define mp make_pair
#define mt make_tuple
#define one(x) memset(x,-1,sizeof(x))
#define zero(x) memset(x,0,sizeof(x))
#ifdef LOCAL
void dmpr(ostream&os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ";
	dmpr(os,args...);
}
#define dmp2(...) dmpr(cerr,__LINE__,##__VA_ARGS__)
#else
#define dmp2(...) void(0)
#endif

using uint=unsigned;
using ull=unsigned long long;

template<class t,size_t n>
ostream& operator<<(ostream&os,const array<t,n>&a){
	return os<<vc<t>(all(a));
}

template<int i,class T>
void print_tuple(ostream&,const T&){
}

template<int i,class T,class H,class ...Args>
void print_tuple(ostream&os,const T&t){
	if(i)os<<",";
	os<<get<i>(t);
	print_tuple<i+1,T,Args...>(os,t);
}

template<class ...Args>
ostream& operator<<(ostream&os,const tuple<Args...>&t){
	os<<"{";
	print_tuple<0,tuple<Args...>,Args...>(os,t);
	return os<<"}";
}

ll read(){
	ll i;
	cin>>i;
	return i;
}

vi readvi(int n,int off=0){
	vi v(n);
	rep(i,n)v[i]=read()+off;
	return v;
}

pi readpi(int off=0){
	int a,b;cin>>a>>b;
	return pi(a+off,b+off);
}

template<class t>
void print_single(t x,int suc=1){
	cout<<x;
	if(suc==1)
		cout<<"\n";
	if(suc==2)
		cout<<" ";
}

template<class t,class u>
void print_single(const pair<t,u>&p,int suc=1){
	print_single(p.a,2);
	print_single(p.b,suc);
}

template<class T>
void print_single(const vector<T>&v,int suc=1){
	rep(i,v.size())
		print_single(v[i],i==int(v.size())-1?suc:2);
}

template<class T>
void print_offset(const vector<T>&v,ll off,int suc=1){
	rep(i,v.size())
		print_single(v[i]+off,i==int(v.size())-1?suc:2);
}

template<class T,size_t N>
void print_single(const array<T,N>&v,int suc=1){
	rep(i,N)
		print_single(v[i],i==int(N)-1?suc:2);
}

template<class T>
void print(const T&t){
	print_single(t);
}

template<class T,class ...Args>
void print(const T&t,const Args&...args){
	print_single(t,2);
	print(args...);
}

string readString(){
	string s;
	cin>>s;
	return s;
}

template<class T>
T sq(const T& t){
	return t*t;
}

void YES(bool ex=true){
	cout<<"YES\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void NO(bool ex=true){
	cout<<"NO\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void Yes(bool ex=true){
	cout<<"Yes\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void No(bool ex=true){
	cout<<"No\n";
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
//#define CAPITAL
/*
void yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<"\n";
	#else
	cout<<"Yes"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void no(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<"\n";
	#else
	cout<<"No"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}*/
void possible(bool ex=true){
	#ifdef CAPITAL
	cout<<"POSSIBLE"<<"\n";
	#else
	cout<<"Possible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}
void impossible(bool ex=true){
	#ifdef CAPITAL
	cout<<"IMPOSSIBLE"<<"\n";
	#else
	cout<<"Impossible"<<"\n";
	#endif
	if(ex)exit(0);
	#ifdef LOCAL
	cout.flush();
	#endif
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

int topbit(signed t){
	return t==0?-1:31-__builtin_clz(t);
}
int topbit(ll t){
	return t==0?-1:63-__builtin_clzll(t);
}
int topbit(ull t){
	return t==0?-1:63-__builtin_clzll(t);
}
int botbit(signed a){
	return a==0?32:__builtin_ctz(a);
}
int botbit(ll a){
	return a==0?64:__builtin_ctzll(a);
}
int botbit(ull a){
	return a==0?64:__builtin_ctzll(a);
}
int popcount(signed t){
	return __builtin_popcount(t);
}
int popcount(ll t){
	return __builtin_popcountll(t);
}
int popcount(ull t){
	return __builtin_popcountll(t);
}
int bitparity(ll t){
	return __builtin_parityll(t);
}
bool ispow2(int i){
	return i&&(i&-i)==i;
}
ll mask(int i){
	return (ll(1)<<i)-1;
}
ull umask(int i){
	return (ull(1)<<i)-1;
}
ll minp2(ll n){
	if(n<=1)return 1;
	else return ll(1)<<(topbit(n-1)+1);
}

bool inc(int a,int b,int c){
	return a<=b&&b<=c;
}

template<class t> void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll rand_int(ll l, ll r) { //[l, r]
	//#ifdef LOCAL
	static mt19937_64 gen;
	/*#else
	static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
	#endif*/
	return uniform_int_distribution<ll>(l, r)(gen);
}

ll rand_int(ll k){ //[0,k)
	return rand_int(0,k-1);
}

template<class t>
void myshuffle(vc<t>&a){
	rep(i,si(a))swap(a[i],a[rand_int(0,i)]);
}

template<class t,class u>
int lwb(const vc<t>&v,const u&a){
	return lower_bound(all(v),a)-v.bg;
}
template<class t,class u>
bool bis(const vc<t>&v,const u&a){
	return binary_search(all(v),a);
}

vvc<int> readGraph(int n,int m){
	vvc<int> g(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		//sc.read(a,b);
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	return g;
}

vvc<int> readTree(int n){
	return readGraph(n,n-1);
}

template<class t>
vc<t> presum(const vc<t>&a){
	vc<t> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
vc<ll> presum(const vi&a){
	vc<ll> s(si(a)+1);
	rep(i,si(a))s[i+1]=s[i]+a[i];
	return s;
}
//BIT で数列を管理するときに使う (CF850C)
template<class t>
vc<t> predif(vc<t> a){
	gnr(i,1,si(a))a[i]-=a[i-1];
	return a;
}
template<class t>
vvc<ll> imos(const vvc<t>&a){
	int n=si(a),m=si(a[0]);
	vvc<ll> b(n+1,vc<ll>(m+1));
	rep(i,n)rep(j,m)
		b[i+1][j+1]=b[i+1][j]+b[i][j+1]-b[i][j]+a[i][j];
	return b;
}

//verify してないや
void transvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void transvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[j][i]=a[i][j];
	}
	a.swap(b);
	transvvc(n,m,args...);
}
//CF854E
void rotvvc(int&n,int&m){
	swap(n,m);
}
template<class t,class... Args>
void rotvvc(int&n,int&m,vvc<t>&a,Args&...args){
	assert(si(a)==n);
	vvc<t> b(m,vi(n));
	rep(i,n){
		assert(si(a[i])==m);
		rep(j,m)b[m-1-j][i]=a[i][j];
	}
	a.swap(b);
	rotvvc(n,m,args...);
}

//ソートして i 番目が idx[i]
//CF850C
template<class t>
vi sortidx(const vc<t>&a){
	int n=si(a);
	vi idx(n);iota(all(idx),0);
	sort(all(idx),[&](int i,int j){return a[i]<a[j];});
	return idx;
}
//vs[i]=a[idx[i]]
//例えば sortidx で得た idx を使えば単にソート列になって返ってくる
//CF850C
template<class t>
vc<t> a_idx(const vc<t>&a,const vi&idx){
	int n=si(a);
	assert(si(idx)==n);
	vc<t> vs(n);
	rep(i,n)vs[i]=a[idx[i]];
	return vs;
}
//CF850C
vi invperm(const vi&p){
	int n=si(p);
	vi q(n);
	rep(i,n)q[p[i]]=i;
	return q;
}

template<class t,class s=t>
s SUM(const vc<t>&a){
	return accumulate(all(a),s(0));
}
template<class t,size_t K,class s=t>
s SUM(const array<t,K>&a){
	return accumulate(all(a),s(0));
}

template<class t>
t MAX(const vc<t>&a){
	return *max_element(all(a));
}

template<class t>
pair<t,int> MAXi(const vc<t>&a){
	auto itr=max_element(all(a));
	return mp(*itr,itr-a.bg);
}

template<class A>
auto MIN(const A&a){
	return *min_element(all(a));
}

template<class t>
pair<t,int> MINi(const vc<t>&a){
	auto itr=min_element(all(a));
	return mp(*itr,itr-a.bg);
}

vi vid(int n){
	vi res(n);iota(all(res),0);
	return res;
}

template<class S>
void soin(S&s){
	sort(all(s));
}

template<class S,class F>
void soin(S&s,F&&f){
	sort(all(s),forward<F>(f));
}

template<class S>
S soout(S s){
	soin(s);
	return s;
}

template<class S>
void rein(S&s){
	reverse(all(s));
}

template<class S>
S reout(S s){
	rein(s);
	return s;
}

template<class t,class u>
pair<t,u>&operator+=(pair<t,u>&a,pair<t,u> b){
	a.a+=b.a;a.b+=b.b;return a;}
template<class t,class u>
pair<t,u>&operator-=(pair<t,u>&a,pair<t,u> b){
	a.a-=b.a;a.b-=b.b;return a;}
template<class t,class u>
pair<t,u> operator+(pair<t,u> a,pair<t,u> b){return mp(a.a+b.a,a.b+b.b);}
template<class t,class u>
pair<t,u> operator-(pair<t,u> a,pair<t,u> b){return mp(a.a-b.a,a.b-b.b);}

template<class t>
t gpp(vc<t>&vs){
	assert(si(vs));
	t res=move(vs.back());
	vs.pop_back();
	return res;
}

template<class t,class u>
void pb(vc<t>&a,const vc<u>&b){
	a.insert(a.ed,all(b));
}

template<class t,class...Args>
vc<t> cat(vc<t> a,Args&&...b){
	(pb(a,forward<Args>(b)),...);
	return a;
}

template<class t,class u>
vc<t>& operator+=(vc<t>&a,u x){
	for(auto&v:a)v+=x;
	return a;
}

template<class t,class u>
vc<t> operator+(vc<t> a,u x){
	return a+=x;
}

template<class t>
vc<t> operator+(const vc<t>&a,const vc<t>&b){
	vc<t> c(max(si(a),si(b)));
	rep(i,si(a))c[i]+=a[i];
	rep(i,si(b))c[i]+=b[i];
	return c;
}

template<class t,class u>
vc<t>& operator-=(vc<t>&a,u x){
	for(auto&v:a)v-=x;
	return a;
}

template<class t,class u>
vc<t>& operator-(vc<t> a,u x){
	return a-=x;
}

template<class t,class u>
void remval(vc<t>&a,const u&v){
	a.erase(remove(all(a),v),a.ed);
}

template<class VS,class u>
void fila(VS&vs,const u&a){
	fill(all(vs),a);
}

template<class t,class u>
int findid(const vc<t>&vs,const u&a){
	auto itr=find(all(vs),a);
	if(itr==vs.ed)return -1;
	else return itr-vs.bg;
}

template<class t>
void rtt(vc<t>&vs,int i){
	rotate(vs.bg,vs.bg+i,vs.ed);
}

bool dbg=false;

//copy-constructor,使えません
//find は lazy と組み合わせても動く (Petrozavodsk 2020w Day9 C)
//reverse は未知数
//erase,insert は動く
//split_cmp も動く
//max_right も動く

//AOJ DSL2G
template<class N>
struct splaytree{
	struct Node{
		using np=Node*;
		np l,r,p;
		bool rev;
		N x;
		Node():l(0),r(0),p(0),rev(false),x(){}
		void clear(){
			l=0;
			r=0;
			p=0;
			rev=0;
		}
		void reverse(){
			rev^=true;
			swap(l,r);
			x.reverse();
		}
		void push(){
			if(rev){
				if(l)l->reverse();
				if(r)r->reverse();
				rev=false;
			}
			if(l)x.pushl(l->x);
			if(r)x.pushr(r->x);
			x.clear();
		}
		np update(){
			x.single();
			if(l)x.updatel(l->x);
			if(r)x.updater(r->x);
			return this;
		}
		int pos(){
			if(p&&p->l==this)return -1;
			if(p&&p->r==this)return 1;
			return 0;
		}
		void prepare(){
			if(pos())
				p->prepare();
			push();
		}
		void rotate(){
			np q=p,c;
			if(pos()==1){
				c=l;
				l=p;
				p->r=c;
			}else{
				c=r;
				r=p;
				p->l=c;
			}
			if(c)c->p=p;
			p=p->p;
			q->p=this;
			if(p&&p->l==q)p->l=this;
			if(p&&p->r==q)p->r=this;
			q->update();
		}
		np splay(){
			prepare();
			while(pos()){
				int a=pos(),b=p->pos();
				if(b&&a==b)p->rotate();
				if(b&&a!=b)rotate();
				rotate();
			}
			return update();
		}
		/* deprecated
		template<class F,class...Args>
		np find(F f,Args&&...args){
			if(!(x.*f)(forward<Args>(args)...))return 0;
			push();
			x.single();
			np a=0;
			if(l)a=l->find(f,forward<Args>(args)...);
			if(a)return a;
			if((x.*f)(forward<Args>(args)...))return splay();
			return r->find(f,forward<Args>(args)...);
		}*/
		np left(){
			if(l)return l->left();
			else return splay();
		}
		np right(){
			if(r)return r->right();
			else return splay();
		}
		/*np root(){
			if(p)return p->root();
			else return this;
		}*/
		void chpar(np c){
			if(c){
				assert(!(c->p));
				c->p=this;
			}
		}
		np linkl(np c){
			assert(!l);
			chpar(l=c);
			return update();
		}
		np linkr(np c){
			assert(!r);
			chpar(r=c);
			return update();
		}
		np linklr(np c,np d){
			assert(!l&&!r);
			chpar(l=c);
			chpar(r=d);
			return update();
		}
		np cutl(){
			if(l){
				l->p=0;
				l=0;
			}
			return update();
		}
		np cutr(){
			if(r){
				r->p=0;
				r=0;
			}
			return update();
		}
		//XIX Opencup GP of Zhejiang A
		np get_next(){
			splay();
			if(!r)return 0;
			else return r->left();
		}
		//linkcut 用
		void expose(){
			for(np a=this;a;a=a->p)a->splay();
			for(np a=this;a->p;a=a->p){
				a->p->r=a;
				a->p->update();
			}
			splay();
		}
		void evert(){
			expose();
			if(l){
				l->reverse();
				l=0;
				update();
			}
		}
		void LClink(np a){
			evert();
			p=a;
		}
		void LCcutchild(){
			expose();
			r=0;
			update();
		}
		void LCcutpar() {
			expose();
			assert(l);
			l->p=0;
			l=0;
			update();
		}
	};
	using np=Node*;
	np head;
	int alloc_total=0;
	splaytree(const splaytree&)=delete;
	void operator=(const splaytree&)=delete;
	splaytree():head(0){}
	~splaytree(){
		int del_total=0;
		while(head){
			del_total++;
			np nx=head->p;
			delete head;
			head=nx;
		}
		assert(alloc_total==del_total);
	}
	//TL,MLが厳しいとき
	//FHC2022 Final E
	//もともと 118 秒くらいのコードが 98 秒になったが…
	/*splaytree(){
		const int S=20000000;
		np buf=new Node[S];
		buf[0].p=0;
		rng(i,1,S)buf[i].p=buf+(i-1);
		head=buf+(S-1);
	}
	~splaytree(){}*/
	np allocnode(){
		if(head){
			np res=head;
			head=res->p;
			return res;
		}else{
			alloc_total++;
			return new Node();
		}
	}
	//読んだ直後,x->p 以外の情報は生きている
	void freenode(np x){
		x->p=head;
		head=x;
	}
	/*vc<np> ps;
	unique_ptr<Node[]> buf;
	splaytree(int n):buf(new Node[n]),ps(n){
		rep(i,n)ps[i]=buf.get()+i;
	}
	//alloc/free 系書いてないわ
	*/
	//FHC2022 Final E/range_set/rect_set
	//assume no duplicate free
	void freetree(np x){
		if(!x)return;
		freetree(x->l);
		freetree(x->r);
		freenode(x);
		//ps.pb(x);
	}
	template<class...Args>
	np nn(Args&&...args){
		np a=allocnode();
		a->l=0;
		a->r=0;
		a->p=0;
		a->x=N(forward<Args>(args)...);
		return a;
	}
	np merge(np a,np b){
		if(!a)return b;
		if(!b)return a;
		return b->splay()->left()->linkl(a->splay());
	}
	//GCJ2022 Round2 D
	template<class...Args>
	np merge(np a,np b,Args...args){
		return merge(merge(a,b),args...);
	}
	template<bool C,class F,class...Args>
	pair<np,np> max_right_sub(np a,F f,Args&&...args){
		N cur;
		np x=0,y=0;
		while(a){
			a->push();
			N nx=a->x;nx.single();
			if(a->l)nx.updatel(a->l->x);
			nx.updatel(cur);
			if((nx.*f)(forward<Args>(args)...)){
				cur=nx;
				x=a;
				a=a->r;
			}else{
				y=a;
				a=a->l;
			}
		}
		if(x){
			x->splay();
			if constexpr(C)x->cutr();
		}
		if(y)y->splay();
		return mp(x,y);
	}
	//max_right で失敗する最初のノードを根にする
	//そのようなものがない場合は false が返ってくる
	template<class F,class...Args>
	bool max_right_splay(np&a,F f,Args&&...args){
		auto [x,y]=max_right_sub<false>(a,f,forward<Args>(args)...);
		if(y){
			a=y;
			return true;
		}else{
			a=x;
			return false;
		}
	}
	//分けた列の右端と左端が返ってくる
	//CF Dytechlab Cup 2022 G (lazy あり)
	template<class F,class...Args>
	pair<np,np> max_right_split(np a,F f,Args&&...args){
		return max_right_sub<true>(a,f,forward<Args>(args)...);
	}
	//XX Opencup GP of Wroclaw D
	//分けた列の右端と左端が返ってくる
	//CF740 D (lazy あり)
	//CF Dytechlab Cup 2022 G (lazy あり)
	template<bool C,class F,class T>
	static pair<np,np> split_sub(np a,F cmp,T v){
		np x=0,y=0;
		while(a){
			a->push();
			if(cmp(a->x,v)){
				x=a;
				a=a->r;
			}else{
				y=a;
				a=a->l;
			}
		}
		if(x){
			x->splay();
			if constexpr(C)x->cutr();
		}
		if(y)y->splay();
		return mp(x,y);
	}
	template<class F,class T>
	pair<np,np> split_cmp(np a,F cmp,T v){
		return split_sub<true>(a,cmp,v);
	}
	//cmp(x,v)=false になる最初の x を根にして返す
	//そのようなものがない場合は false が返ってくる
	//FHC2022 Final E/range_set/rect_set
	template<class F,class T>
	bool lower_bound_cmp(np&a,F cmp,T v){
		auto [x,y]=split_sub<false>(a,cmp,v);
		if(y){
			a=y;
			return true;
		}else{
			//not verified?
			a=x;
			return false;
		}
	}
	//XIX Opencup GP of Zhejiang A
	//FHC2022 Final E/range_set/rect_set
	template<class F>
	void insert_cmp(np&x,F cmp,np v){
		assert(!v->l&&!v->r&&!v->p&&!v->rev);
		//auto [a,b]=split_cmp(x,f,v->x);
		//x=v->linklr(a,b);
		if(!x){
			x=v;
			return;
		}else{
			np p=0;
			bool l;
			while(x){
				x->push();
				p=x;
				if(cmp(x->x,v->x)){
					l=false;
					x=x->r;
				}else{
					l=true;
					x=x->l;
				}
			}
			if(l){
				p->linkl(v);
			}else{
				p->linkr(v);
			}
			x=v->splay();
		}
	}
	//XX Opencup GP of Wroclaw D
	//FHC2022 Final E/range_set/rect_set
	template<class F,class...Args>
	void emplace_cmp(np&x,F f,Args&&...args){
		insert_cmp(x,f,nn(forward<Args>(args)...));
	}
	//FHC2022 Final E/range_set/rect_set
	template<class...Args>
	void emplace(np&x,Args&&...args){
		emplace_cmp(x,less<N>(),forward<Args>(args)...);
	}
	//XX Opencup GP of Wroclaw D
	pair<np,np> erase_sub(np x){
		x->splay();
		if(x->l)x->l->p=0;
		if(x->r)x->r->p=0;
		freenode(x);
		return mp(x->l,x->r);
	}
	//CF Dytechlab Cup 2022 G
	void erase(np&x){
		auto [a,b]=erase_sub(x);
		x=merge(a,b);
	}
	//FHC2022 Final E/range_set/rect_set
	//less,eq,
	template<class F,class T,class G>
	bool erase_cmp_eq(np&x,F f,G g,T v){
		if(lower_bound_cmp(x,f,v)&&g(x->x,v)){
			erase(x);
			return true;
		}
		return false;
	}
	//FHC2022 Final E/range_set/rect_set
	template<class T>
	bool erase(np&x,T v){
		return erase_cmp_eq(x,less<N>(),equal_to<N>(),v);
	}
	//Petrozavodsk 2020w Day9 H
	np isolate(np x){
		x->splay();
		if(x->l)x->l->p=0;
		if(x->r)x->r->p=0;
		np res=merge(x->l,x->r);
		x->x.single();
		x->clear();
		return res;
	}
	template<class t>
	np build(vc<t> v){
		vc<np> cur;
		for(auto z:v)cur.pb(nn(z));
		while(cur.size()>1){
			int s=cur.size();
			vc<np> nx((s+1)/2);
			for(int i=0;i<s;i+=2){
				if(i+1<s)nx[i/2]=merge(cur[i],cur[i+1]);
				else nx[i/2]=cur[i];
			}
			swap(nx,cur);
		}
		return cur[0];
	}
	/*
	//NOT VERIFIED
	//lower_bound したものを根に移して node を返す.
	//lower_bound の結果が end だと空が返ってくるらしい
	//USACO2021 USOPEN Platinum A
	template<class F>
	np lower_bound_cmp(np a,F cmp,N v){
		auto [x,y]=split_cmp(a,cmp,v);
		np res=nullptr;
		if(y)res=y->left();
		merge(x,res);
		if(res)res->splay();
		return res;
	}
	*/
	//XIX Opencup GP of Zhejiang A
	//a-b なる部分を取り出し,x,y(a-b),z を返す
	//a と b が異なる木に属する,また,a と b の順序がおかしい場合,何が起きるかは不明
	tuple<np,np,np> split_range(np a,np b){
		{//debug
			a->splay();
			b->splay();
			int lastpos;
			auto c=a;
			while(c&&c!=b){
				lastpos=c->pos();
				c=c->p;
			}
			assert(c==b);
			assert(lastpos==-1);
		}
		a->splay();
		np x=a->l;
		a->cutl();
		b->splay();
		np z=b->r;
		b->cutr();
		return mt(x,b,z);
	}
	//CF743F(TLE)
	//The 2022 ICPC Asia Nanjing Regional Contest H
	template<class F>
	void weighted_merge_rec_cmp(np&tar,F f,np x){
		if(!x)return;
		x->push();
		np l=x->l,r=x->r;
		x->x.single();
		x->clear();
		weighted_merge_rec_cmp(tar,f,l);
		insert_cmp(tar,f,x);
		weighted_merge_rec_cmp(tar,f,r);
	}
	template<class F>
	np weighted_merge_cmp(np a,F f,np b){
		if(!a)return b;
		if(!b)return a;
		if(a->x.len<b->x.len)swap(a,b);
		weighted_merge_rec_cmp(a,f,b);
		return a;
	}
	//Petrozavodsk 2020w Day9 C
	void enumerate(np x,vc<N>&dst){
		if(!x)return;
		x->push();
		enumerate(x->l,dst);
		dst.pb(x->x);
		enumerate(x->r,dst);
	}
	/* deprecated
	//Petrozavodsk 2020w Day9 H
	template<class F>
	np insert(np r,np x,F f){
		np a,b;tie(a,b)=split(r,f,x->x);
		return merge(merge(a,x),b);
	}
	template<class F,class...Args>
	np insert(np r,F f,Args&&...args){
		np x=nn(forward<Args>(args)...);
		np a,b;tie(a,b)=split(r,f,x->x);
		return merge(merge(a,x),b);
	}
	//左の列の根は右端とは限らない!
	//右の列の根は左端だと思う
	template<class F,class...Args>
	pair<np,np> split(np a,F f,Args&&...args){
		if(!a)return {0,0};
		np b=a->find(f,forward<Args>(args)...);
		if(b){
			np c=b->l;
			return {c,b->cutl()};
		}
		return {a,0};
	}
	//GCJ2022 Round2 D
	tuple<np> split_by_len(np a){
		return a;
	}
	template<class...Args>
	auto split_by_len(np a,int len,Args...args){
		assert((!a&&len==0)||inc(0,len,a->x.len));
		auto [b,c]=split(a,&N::find_by_len,len);
		assert(len==0);
		return tuple_cat(tuple{b},split_by_len(c,args...));
	}
	//Petrozavodsk 2020w Day9 C
	template<class F>
	np weighted_merge_rec(np x,np tar,F f){
		if(!x)return tar;
		x->push();
		tar=weighted_merge_rec(x->l,tar,f);
		tar=weighted_merge_rec(x->r,tar,f);
		x->x.single();
		x->clear();
		return insert(tar,x,f);
	}
	//Petrozavodsk 2020w Day9 C
	template<class F>
	np weighted_merge(np a,np b,F f){
		if(!a)return b;
		if(!b)return a;
		if(a->x.sz<b->x.sz)swap(a,b);
		return weighted_merge_rec(b,a,f);
	}
	*/
};
//デフォルトコンストラクターが null node になっているべき (例えば len=0)
//N::reverse
//N::push→ pushl,pushr
//副作用なし,1個の子にpush
//N::clear
//lazy tagを消去
//N::single
//ノード単体の情報を元に部分木情報を初期化
//N::updatel,updater
//N::find
//find はその部分木内に目標とするノードがあるかどうかを返す
//split のやり方を変えたい
//max_right のノリで split をする
//split_cmp は cmp(x,v) が true になる最大の x を見つけてそれで分離
//↓deprecared
//split は find で見つけたものが右の部分木の left になるように分離する
//普通に a<b を渡すと lower_bound と同じ効果が得られる
//split_by_len で左 len 個とそれ以外に分離する
//find_by_len という比較関数が定義されていないと破壊

template<class N>
struct linkcut{
	using Node=typename splaytree<N>::Node;
	using np=typename Node::np;
	np x;
	linkcut(const linkcut&)=delete;
	void operator=(const linkcut&)=delete;
	linkcut(int n){x=new Node[n];}
	~linkcut(){delete[] x;}
	
	int lca(int aa,int bb){
		np a=x+aa,b=x+bb;
		a->expose();
		b->expose();
		if(!a->p)return -1;
		
		np d=a;
		while(a->p!=b){
			if(a->pos()==0)
				d=a->p;
			a=a->p;
		}
		if(a==b->l)return d-x;
		else return b-x;
	}
	//child->par
	void link(int a,int b){
		x[a].LClink(x+b);
	}
	void cutpar(int a){
		x[a].LCcutpar();
	}
	void expose(int a){
		x[a].expose();
	}
	void evert(int a){
		x[a].evert();
	}
	void cutchild(int a){
		x[a].LCcutchild();
	}
	void expose_path(int a,int b){
		x[a].evert();
		x[b].LCcutchild();
	}
	N&operator[](int i){
		return x[i].x;
	}
};

struct N{
	int val,sum;
	N(int v=0):val(v),sum(v){}
	void reverse(){}
	void pushl(N&){}
	void pushr(N&){}
	void clear(){}
	void add(int v){
		val+=v;
		sum+=v;
	}
	void single(){
		sum=val;
	}
	void updatel(const N&x){
		sum+=x.sum;
	}
	void updater(const N&x){
		sum+=x.sum;
	}
};

void slv(){
	int n,k;cin>>n>>k;
	vi a=readvi(n);
	
	linkcut<N> lc(2*(n+1));
	rep(i,n+1){
		lc.link(i,i+n+1);
	}
	rep(i,n){
		lc.link(i+n+1,i+1+n+1);
	}
	
	set<int> avail;
	rep(i,n+1)avail.insert(i);
	vi ans;
	rep(i,n){
		for(auto itr=avail.lower_bound(a[i]-k);
			itr!=avail.ed&&*itr<a[i];
			itr=avail.erase(itr)){
			
			int v=*itr;
			lc.cutpar(v);
			lc.expose(v);
			lc[v].add(1);
			int to=min(v+k,n);
			lc.link(v,to);
		}
		{
			int v=n+1+a[i]-1;
			lc.cutpar(v);
			lc.expose(v);
			lc[v].add(1);
			lc.link(v,a[i]);
		}
		
		lc.expose(0);
		ans.pb(lc[0].sum);
	}
	print(ans);
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	
	if(dbg){
		while(1)slv();
	}else{
		int t;cin>>t;rep(_,t)
		slv();
	}
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

3
7 2
4 7 3 6 1 2 5
11 3
10 7 4 9 6 8 5 1 3 2 11
9 2
1 2 3 7 8 9 4 5 6

output:

1 2 3 3 4 4 4
1 2 3 3 3 3 3 4 4 4 4
1 1 2 3 4 4 4 5 5

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 81ms
memory: 3912kb

input:

40319
1 1
1
2 1
1 2
2 1
2 1
2 2
1 2
2 2
2 1
3 1
1 2 3
3 1
1 3 2
3 1
2 1 3
3 1
2 3 1
3 1
3 1 2
3 1
3 2 1
3 2
1 2 3
3 2
1 3 2
3 2
2 1 3
3 2
2 3 1
3 2
3 1 2
3 2
3 2 1
3 3
1 2 3
3 3
1 3 2
3 3
2 1 3
3 3
2 3 1
3 3
3 1 2
3 3
3 2 1
4 1
1 2 3 4
4 1
1 2 4 3
4 1
1 3 2 4
4 1
1 3 4 2
4 1
1 4 2 3
4 1
1 4 3 2
4 1
...

output:

1
1 2
1 2
1 1
1 1
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 2 3
1 1 2
1 2 2
1 1 2
1 2 2
1 2 2
1 2 2
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 4
1 2 3 ...

result:

ok 40319 lines

Test #3:

score: 0
Accepted
time: 183ms
memory: 3616kb

input:

50000
10 2
9 3 1 10 2 4 6 5 7 8
10 5
8 3 4 1 2 7 5 9 10 6
10 7
6 7 5 9 1 4 10 2 8 3
10 10
3 1 10 2 6 8 9 4 5 7
10 7
8 9 7 5 6 2 1 10 3 4
10 1
7 1 10 8 9 3 4 6 2 5
10 1
6 7 4 10 3 5 8 9 1 2
10 9
4 6 9 7 3 8 5 1 10 2
10 4
2 6 9 3 10 5 1 4 7 8
10 1
7 4 10 3 6 9 2 5 1 8
10 6
9 5 2 3 1 8 10 7 6 4
10 4
3 ...

output:

1 2 3 4 4 4 5 5 5 5
1 2 2 2 2 2 2 2 2 2
1 1 1 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1
1 2 2 2 2 2 2 2 2 2
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
1 1 1 1 1 1 1 1 2 2
1 2 3 3 3 3 3 3 3 3
1 2 3 4 5 6 7 8 9 10
1 2 2 2 2 2 2 2 2 2
1 1 2 2 3 3 3 3 3 3
1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 2 2 2 2 2 2...

result:

ok 50000 lines

Test #4:

score: 0
Accepted
time: 287ms
memory: 3680kb

input:

5000
100 2
63 78 43 82 37 72 75 31 48 32 69 7 71 5 38 100 85 45 12 83 92 41 81 19 21 14 57 74 87 73 59 4 40 91 55 53 20 60 96 17 64 24 9 22 2 62 84 90 46 61 95 50 26 13 34 79 8 65 54 70 1 56 15 88 67 28 27 98 3 39 51 93 52 11 16 10 97 94 36 18 80 30 66 49 29 42 77 35 99 44 25 68 47 89 33 86 76 23 58...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 22 23 24 25 26 26 27 27 28 29 29 30 31 32 32 33 34 35 36 37 38 39 40 40 40 40 41 41 42 43 44 44 45 46 46 46 46 46 46 46 46 46 47 48 48 49 49 49 49 49 49 49 49 49 49 49 49 49 49 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50
1 2 3 4 5...

result:

ok 5000 lines

Test #5:

score: 0
Accepted
time: 285ms
memory: 3692kb

input:

5000
100 3
23 52 62 18 85 78 19 65 26 46 100 33 57 32 3 13 12 16 81 75 72 2 92 22 80 95 60 45 94 24 43 73 67 35 77 15 25 47 56 28 48 36 10 59 93 27 9 34 54 58 55 91 87 31 76 42 11 68 96 97 89 83 79 74 20 8 7 70 38 84 6 64 63 99 53 98 49 66 90 30 69 40 50 61 37 1 39 29 5 4 82 44 41 86 51 14 21 88 17 ...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 17 18 19 20 20 21 21 21 22 23 24 24 24 24 24 25 25 25 25 25 26 26 27 27 27 28 28 28 28 28 28 28 28 28 29 30 30 30 30 30 31 31 31 31 31 31 31 31 32 32 32 33 33 33 33 33 33 33 33 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34
1 2 3 4 5...

result:

ok 5000 lines

Test #6:

score: 0
Accepted
time: 256ms
memory: 3620kb

input:

5000
100 8
69 26 68 33 32 41 79 80 22 43 94 31 87 15 7 11 25 4 28 12 13 19 83 48 40 60 76 58 34 81 93 10 55 37 3 59 71 89 49 52 21 82 2 85 84 62 16 45 57 36 39 51 95 50 70 30 42 47 77 64 23 88 1 91 63 61 97 73 67 9 99 53 100 54 18 29 96 72 75 35 98 56 92 46 6 27 65 74 20 86 14 38 78 44 17 66 90 5 8 ...

output:

1 2 3 4 4 5 6 6 7 7 8 8 9 10 11 11 11 11 11 11 11 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
1 2 3 4 5 6 6...

result:

ok 5000 lines

Test #7:

score: 0
Accepted
time: 247ms
memory: 3852kb

input:

5000
100 8
66 22 6 89 68 15 82 100 62 26 43 79 76 47 32 25 27 33 50 75 77 92 42 40 11 81 54 31 28 7 87 58 96 45 21 91 97 98 13 86 69 19 10 61 72 44 36 24 51 64 55 14 34 46 2 65 59 41 17 5 74 18 57 20 94 3 90 88 78 12 93 8 48 85 37 80 95 9 71 52 83 35 73 56 60 84 39 30 16 49 38 23 1 70 4 53 29 99 63 ...

output:

1 2 3 4 5 6 7 8 8 9 10 11 11 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
1 2 3 4 5 ...

result:

ok 5000 lines

Test #8:

score: 0
Accepted
time: 192ms
memory: 3912kb

input:

5000
100 8
25 36 39 50 79 40 3 19 91 97 72 6 62 54 33 66 78 26 45 13 43 12 95 94 89 17 70 41 65 52 4 5 21 90 82 68 67 63 83 11 99 57 84 85 98 1 87 74 14 35 31 37 10 30 80 81 60 88 56 32 86 96 53 61 58 71 38 48 55 44 8 24 64 75 9 22 93 34 2 47 100 46 15 23 73 28 76 16 29 49 7 18 51 92 59 77 42 69 20 ...

output:

1 2 3 4 5 5 6 7 8 9 10 10 11 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
1 2 2 3 3 ...

result:

ok 5000 lines

Test #9:

score: 0
Accepted
time: 243ms
memory: 5048kb

input:

50
10000 8
274 974 424 4088 762 1098 5354 5693 8734 243 1673 3993 972 5992 9422 4459 6504 4367 7594 9625 4021 7371 3760 1834 2602 5886 2573 5608 2338 5869 6036 4523 5430 9915 5902 979 6434 6013 8881 9136 7450 6065 9790 9051 9545 9938 8604 7526 5829 2766 1433 6053 9650 1712 5928 9002 3854 1152 2778 1...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 1...

result:

ok 50 lines

Test #10:

score: 0
Accepted
time: 886ms
memory: 18944kb

input:

5
100000 1
98420 62278 61893 21653 60003 72714 31478 93221 52310 28889 69896 3599 74920 72182 84226 27631 5337 74459 11956 99033 59122 23980 95516 12262 88093 55256 85020 35044 18848 86156 81566 44214 73514 22994 25629 83306 81401 39189 88840 6980 69761 54464 55186 76771 43620 59242 72845 61388 8089...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #11:

score: 0
Accepted
time: 825ms
memory: 19184kb

input:

5
100000 2
64399 63674 21280 16692 49293 81297 84388 39242 34119 80513 17260 59983 26842 94045 2753 90512 76105 17987 34265 70348 71403 14911 70011 10600 40925 98037 90705 27361 4364 50825 57345 18247 50196 5511 48862 32797 91905 80229 20782 37621 98115 90270 82476 87164 21970 2281 24796 30439 22752...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #12:

score: 0
Accepted
time: 658ms
memory: 18200kb

input:

5
100000 8
76194 71588 27212 86287 69258 56624 74892 60254 94291 64851 31220 38875 48689 5689 19483 783 91032 21265 71981 9390 12949 95047 80129 11912 8898 32471 80931 40552 30401 12358 1934 9916 15511 55750 69816 78633 20401 93320 27466 66319 58076 48154 96212 17882 83673 81027 12602 21517 35704 72...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #13:

score: 0
Accepted
time: 535ms
memory: 18032kb

input:

5
100000 8
3405 68273 96596 86470 49252 63887 24398 4672 37187 52435 64116 60894 44120 174 56748 45679 79691 42923 96599 22730 44310 4403 27462 85208 80277 4743 31252 67178 13357 33995 96056 99917 48186 18377 68417 90737 89033 53482 24664 63539 94248 14199 39211 91709 95405 80931 49139 42635 85614 4...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #14:

score: 0
Accepted
time: 435ms
memory: 18092kb

input:

5
100000 200
50573 49627 37560 74624 24741 5634 18355 52180 80358 20343 3290 67242 53105 69545 58400 63857 1919 83527 91130 5971 87369 14265 38136 22901 24675 63793 72964 10635 95913 38437 92826 7577 51476 51296 17582 25422 33321 67027 94755 85748 85877 1500 38644 23051 23500 5436 54539 53497 36574 ...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 61 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

result:

ok 5 lines

Test #15:

score: 0
Accepted
time: 410ms
memory: 18048kb

input:

5
100000 250
56757 72017 30612 78109 72164 46319 69441 25719 98152 51933 90517 24067 56286 98158 63438 53253 22127 29504 11523 8026 97487 88635 52047 99706 44247 2543 98023 71789 10194 56377 27028 52794 31965 26002 7684 73365 71406 63821 83310 4153 99018 96928 30839 93930 93540 27521 42819 35021 446...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 49 50 50 51 52 53 54 55 56 57 58 59 60 61 61 62 63 64 65 66 67 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 91 92 93 94 95 96 97 ...

result:

ok 5 lines

Test #16:

score: 0
Accepted
time: 396ms
memory: 18052kb

input:

5
100000 300
23863 80414 89139 3910 8202 6420 53655 76862 59580 53928 88205 63535 59974 64102 28799 79017 7095 23539 18771 44709 7486 36463 11983 25411 76459 79748 33452 63391 38090 55959 80212 91623 14717 67920 91667 53323 89899 50371 76320 3757 66846 51801 3021 98128 32712 92509 37623 43549 2404 7...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 65 66 67 68 69 70 71 72 73 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 5 lines

Test #17:

score: 0
Accepted
time: 403ms
memory: 17920kb

input:

5
100000 350
49653 69416 1853 6195 82300 68311 68289 57710 31311 64330 16354 52843 59334 62793 80334 61706 4602 44229 99687 27717 48458 3622 41078 91089 53537 69306 93848 39125 88262 5919 97282 61602 9293 7376 37923 5797 14923 67281 12721 28734 37991 53258 51908 12239 91237 48245 81275 82548 27991 9...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 77 78 79 80 81 82 83 84 85 86 87 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 5 lines

Test #18:

score: 0
Accepted
time: 396ms
memory: 17964kb

input:

5
100000 400
91792 48042 52417 73232 21947 65806 66142 73914 95734 24445 48406 89399 30017 1970 46594 56984 80575 25224 66859 8705 30468 39329 97781 78798 72534 92697 63105 67623 98574 5976 55606 25304 41727 305 94554 58956 26915 24387 7537 72120 86347 74624 75941 75628 26879 37420 21455 47764 2652 ...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 56 57 58 59 60 61 62 63 64 65 66 67 67 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 84 85 86 87 87 88 88 89 90 90 91 92 93 94 95 96 ...

result:

ok 5 lines

Test #19:

score: 0
Accepted
time: 397ms
memory: 18096kb

input:

5
100000 450
2285 69105 49968 46821 96944 44917 20591 11352 8458 14753 98898 38996 6850 96883 62253 15680 70809 43657 27782 62096 89801 64037 85400 84084 13690 3453 42336 90568 62795 48611 44747 53002 8198 47649 84827 24886 65173 47274 11353 53074 28303 32675 97926 88402 8406 74103 4429 89564 26089 ...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 44 45 46 47 48 49 50 51 52 53 54 55 56 56 57 57 58 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 95 96 96 ...

result:

ok 5 lines

Test #20:

score: 0
Accepted
time: 398ms
memory: 17824kb

input:

5
100000 500
63410 63303 97875 92089 75834 33020 95290 86143 26248 62711 96880 6777 87757 55934 22455 47873 96526 8805 26904 69948 3848 23324 97036 36751 22957 18542 19217 76123 71097 23646 18556 74250 18170 97821 4994 8326 76619 56014 9504 29853 63857 87484 31849 90433 62219 91293 97282 20202 10793...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 32 32 33 34 35 36 37 38 39 40 41 42 43 44 44 45 46 47 48 49 50 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 67 68 69 70 70 70 71 72 73 73 74 75 76 77 78 79 80 80 80 81 82 83 83 83 83 84 85 86 86 87 87 87 ...

result:

ok 5 lines

Test #21:

score: 0
Accepted
time: 386ms
memory: 18044kb

input:

5
100000 600
95029 10951 68852 34533 69076 78832 84875 50191 47499 47175 19072 28210 32919 81599 83725 93417 80373 25651 86085 96556 44252 3297 99816 3774 36958 63228 70734 48796 21074 13308 70636 12715 12282 33411 57556 91959 44142 31559 700 96311 66607 9982 94835 67381 16771 92072 2217 32134 60287...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 68 68 68 69 70 70 71 72 73 73 74 75 76 76 76 76 77 78 79 80 81 82 83 84 85 85 85 86 86 87 88 89 90 91 ...

result:

ok 5 lines

Test #22:

score: 0
Accepted
time: 411ms
memory: 17972kb

input:

5
100000 800
76978 71580 79923 3498 41229 53891 65845 90565 12537 90114 99522 34874 39685 12300 46452 86597 96812 56287 43586 46337 58052 50614 69379 25133 48310 33430 48143 8768 50239 8858 30304 6847 75721 97981 85136 64864 59376 26151 71796 95546 86857 66414 55602 25204 43427 88735 27304 657 46313...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 48 49 50 51 52 53 53 54 55 56 56 57 58 59 59 60 61 61 61 62 63 64 64 64 65 66 66 67 68 69 70 71 71 71 72 72 73 74 75 76 77 77 78 79 80 81 81 82 82 83 84 84 84 85 86 ...

result:

ok 5 lines

Test #23:

score: 0
Accepted
time: 357ms
memory: 18308kb

input:

5
100000 8
85985 96895 44302 35135 66648 71267 8380 12977 13301 13226 31919 17721 60690 76973 91090 32432 18468 39333 15036 90566 40189 84143 96571 46321 78801 11899 52417 46413 32747 11290 74522 45325 84470 84377 43170 49694 926 72546 13687 22821 89794 36589 99939 59264 56841 54638 64763 55750 6893...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #24:

score: 0
Accepted
time: 356ms
memory: 18060kb

input:

5
100000 8
41683 62741 72083 58940 3083 69325 18987 24307 77820 4975 98899 97986 78727 71545 8809 59423 64776 51915 15705 10234 11615 23317 24939 7745 35998 80966 67679 45340 15361 46577 90016 65144 40123 42750 46207 60088 72781 69096 17339 17814 66139 9204 9731 71148 49600 34719 35468 33633 61451 3...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok 5 lines

Test #25:

score: 0
Accepted
time: 209ms
memory: 18088kb

input:

5
100000 33333
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 5 lines

Test #26:

score: 0
Accepted
time: 192ms
memory: 18120kb

input:

5
100000 66667
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 5 lines

Test #27:

score: 0
Accepted
time: 225ms
memory: 18012kb

input:

5
100000 20000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 5 lines

Test #28:

score: 0
Accepted
time: 193ms
memory: 18056kb

input:

5
100000 80000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 5 lines

Test #29:

score: 0
Accepted
time: 193ms
memory: 18284kb

input:

5
100000 50000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok 5 lines