結果

問題 No.318 学学学学学
ユーザー tailstails
提出日時 2015-12-11 18:35:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 150,744 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2023-09-04 17:32:31
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 21 ms
4,528 KB
testcase_02 AC 25 ms
4,676 KB
testcase_03 AC 17 ms
4,380 KB
testcase_04 AC 22 ms
4,560 KB
testcase_05 AC 136 ms
9,868 KB
testcase_06 AC 120 ms
7,292 KB
testcase_07 AC 112 ms
6,580 KB
testcase_08 AC 105 ms
5,896 KB
testcase_09 AC 101 ms
5,376 KB
testcase_10 AC 89 ms
5,044 KB
testcase_11 AC 130 ms
9,828 KB
testcase_12 AC 111 ms
7,300 KB
testcase_13 AC 97 ms
6,476 KB
testcase_14 AC 91 ms
5,880 KB
testcase_15 AC 80 ms
5,528 KB
testcase_16 AC 71 ms
4,956 KB
testcase_17 AC 92 ms
7,252 KB
testcase_18 AC 88 ms
7,252 KB
testcase_19 AC 92 ms
7,284 KB
testcase_20 AC 59 ms
5,204 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,384 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct S{int u,v;};

#define nmax (1<<17)
map<int,int>last;
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){if(p->u)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