結果
問題 | No.318 学学学学学 |
ユーザー | AEn |
提出日時 | 2023-05-30 02:01:14 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 466 ms / 2,000 ms |
コード長 | 2,879 bytes |
コンパイル時間 | 308 ms |
コンパイル使用メモリ | 86,520 KB |
実行使用メモリ | 117,132 KB |
最終ジャッジ日時 | 2023-08-28 00:19:24 |
合計ジャッジ時間 | 8,593 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
80,148 KB |
testcase_01 | AC | 131 ms
83,920 KB |
testcase_02 | AC | 138 ms
86,264 KB |
testcase_03 | AC | 133 ms
82,804 KB |
testcase_04 | AC | 135 ms
84,812 KB |
testcase_05 | AC | 286 ms
117,132 KB |
testcase_06 | AC | 466 ms
105,696 KB |
testcase_07 | AC | 401 ms
100,676 KB |
testcase_08 | AC | 306 ms
98,012 KB |
testcase_09 | AC | 231 ms
95,788 KB |
testcase_10 | AC | 176 ms
94,432 KB |
testcase_11 | AC | 274 ms
117,040 KB |
testcase_12 | AC | 225 ms
105,148 KB |
testcase_13 | AC | 197 ms
100,836 KB |
testcase_14 | AC | 179 ms
97,928 KB |
testcase_15 | AC | 171 ms
95,884 KB |
testcase_16 | AC | 153 ms
94,076 KB |
testcase_17 | AC | 250 ms
104,356 KB |
testcase_18 | AC | 183 ms
104,540 KB |
testcase_19 | AC | 250 ms
104,344 KB |
testcase_20 | AC | 172 ms
92,732 KB |
testcase_21 | AC | 89 ms
71,476 KB |
testcase_22 | AC | 88 ms
71,300 KB |
testcase_23 | AC | 88 ms
71,484 KB |
testcase_24 | AC | 89 ms
71,484 KB |
testcase_25 | AC | 89 ms
71,460 KB |
testcase_26 | AC | 88 ms
71,040 KB |
testcase_27 | AC | 89 ms
71,484 KB |
testcase_28 | AC | 90 ms
71,260 KB |
ソースコード
bucket_size = 350 class SqrtDecomposition: def __init__(self, N, init,ide): """ 平方分割して、各バケット内での値を計算 """ self.N = N self.data = [] self.lazydata = [] d = [] if init==0: for i in range(bucket_size): self.data.append([ide]*bucket_size) self.lazydata.append(None) else: for i in range(self.N): if (i+1)%bucket_size==0: d.append(init[i]) self.data.append(d) self.lazydata.append(None) d = [] else: d.append(init[i]) if d: self.data.append(d+[ide]*(bucket_size-len(d))) self.lazydata.append(None) def update(self, l, r, x): """0-indexedの[l,r)にxで更新""" # 更新処理をかく a1, b1 = l//bucket_size, l%bucket_size a2, b2 = r//bucket_size, r%bucket_size if a1==a2: if self.lazydata[a1] != None: for i in range(bucket_size): if b1<=i<b2: self.data[a1][i] = x else: self.data[a1][i] = self.lazydata[a1] self.lazydata[a1] = None else: for i in range(b1,b2): self.data[a1][i] = x else: if self.lazydata[a1] != None: for i in range(bucket_size): if i>=b1: self.data[a1][i] = x else: self.data[a1][i] = self.lazydata[a1] self.lazydata[a1] = None else: for i in range(b1,bucket_size): self.data[a1][i] = x for i in range(a1+1, a2): self.lazydata[i] = x if self.lazydata[a2] != None: for i in range(bucket_size): if i<b2: self.data[a2][i] = x else: self.data[a2][i] = self.lazydata[a2] self.lazydata[a2] = None else: for i in range(b2): self.data[a2][i] = x def get(self, i): """0-indexedのi番目を取得で計算""" a, b = i//bucket_size, i%bucket_size if self.lazydata[a] != None: return self.lazydata[a] else: return self.data[a][b] from collections import defaultdict N = int(input()) a = list(map(int, input().split())) d = defaultdict(list) for i in range(N): d[a[i]].append(i) sd = SqrtDecomposition(N,a,0) a = sorted(list(set(a))) for nn in a: sd.update(d[nn][0],d[nn][-1]+1,nn) ans = [sd.get(i) for i in range(N)] print(*ans)