結果

問題 No.318 学学学学学
ユーザー tailstails
提出日時 2015-12-11 18:05:16
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 723 bytes
コンパイル時間 2,956 ms
コンパイル使用メモリ 143,988 KB
実行使用メモリ 5,328 KB
最終ジャッジ日時 2023-10-13 11:10:09
合計ジャッジ時間 6,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct S{int u,v;};

#define nmax (1<<17)
int last[nmax];
S segs[nmax*2];

void fill(int a,int b,int v,int i,int l,int w){
	S*p=segs+i;
	if(v<=p->u)return;
	if(v>=p->v&&a<=l&&b>l+w-2){p->u=p->v=v;return;}
	S*c0=segs+(i*2+1);
	S*c1=c0+1;
	if(a<l+w/2)fill(a,b,v,i*2+1,l,w/2);
	if(b>=l+w/2)fill(a,b,v,i*2+2,l+w/2,w/2);
	p->u=min(c0->u,c1->u);
	p->v=max(c0->v,c1->v);
}

void show(int n,int i,int l,int w){
	S*p=segs+i;
	if(p->u==p->v){for(;w--;)cout<<p->u<<" ";return;}
	show(n,i*2+1,l,w/2);
	if(n>=l+w/2)show(n,i*2+2,l+w/2,w/2);
}

int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;++i){
		int a;
		cin >> a;
		fill(last[a]?:i,i,a,0,0,nmax);
		last[a]=i+1;
	}
	show(n,0,0,nmax);
}
0