結果
問題 | No.2076 Concon Substrings (ConVersion) |
ユーザー | Navier_Boltzmann |
提出日時 | 2023-11-12 06:29:22 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,854 bytes |
コンパイル時間 | 406 ms |
コンパイル使用メモリ | 81,700 KB |
実行使用メモリ | 80,344 KB |
最終ジャッジ日時 | 2023-11-12 06:29:27 |
合計ジャッジ時間 | 4,461 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
57,812 KB |
testcase_01 | AC | 46 ms
57,812 KB |
testcase_02 | AC | 46 ms
57,812 KB |
testcase_03 | AC | 46 ms
57,812 KB |
testcase_04 | AC | 50 ms
57,812 KB |
testcase_05 | AC | 122 ms
80,344 KB |
testcase_06 | AC | 56 ms
67,020 KB |
testcase_07 | AC | 90 ms
77,148 KB |
testcase_08 | AC | 91 ms
77,148 KB |
testcase_09 | AC | 89 ms
77,148 KB |
testcase_10 | WA | - |
testcase_11 | AC | 46 ms
57,812 KB |
testcase_12 | AC | 46 ms
57,812 KB |
testcase_13 | AC | 46 ms
57,812 KB |
testcase_14 | AC | 47 ms
57,812 KB |
testcase_15 | AC | 128 ms
77,604 KB |
testcase_16 | WA | - |
testcase_17 | AC | 113 ms
77,988 KB |
testcase_18 | AC | 99 ms
77,696 KB |
testcase_19 | WA | - |
testcase_20 | AC | 92 ms
77,212 KB |
testcase_21 | AC | 46 ms
57,812 KB |
testcase_22 | AC | 85 ms
76,976 KB |
testcase_23 | AC | 81 ms
76,868 KB |
testcase_24 | AC | 69 ms
73,276 KB |
testcase_25 | WA | - |
testcase_26 | AC | 113 ms
77,748 KB |
testcase_27 | AC | 92 ms
77,120 KB |
testcase_28 | WA | - |
testcase_29 | AC | 84 ms
76,860 KB |
testcase_30 | AC | 125 ms
77,988 KB |
testcase_31 | WA | - |
ソースコード
from heapq import * from itertools import * from functools import * from collections import * import sys,math input = sys.stdin.readline N,A,B = map(int,input().split()) S = input()[:-1] S = S.replace('con','X') X = [] for g,r in groupby(S): n = len(list(r)) if g=='X': X.append(n) if len(X)==0: print(0) exit() ans = 0 def segfunc(x, y): return min(x,y) class SegTree: """ Segment Tree """ def __init__(self, init_val, segfunc, ide_ele): """ 初期化 init_val: 配列の初期値 """ n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num # 配列の値を葉にセット for i in range(n): self.tree[self.num + i] = init_val[i] # 構築していく for i in range(self.num - 1, 0, -1): self.tree[i] = segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): """ k番目の値をxに更新 k: index(0-index) x: update value """ k += self.num self.tree[k] = x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): """ [l, r)のsegfuncしたものを得る l: index(0-index) r: index(0-index) """ res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res INF = (1<<30) M = max(X) T = SegTree([(INF,-1) for _ in range(M+1)],min,(INF,-1)) C = Counter(X) for k,v in C.items(): T.update(k,(k,v)) # print(X) for i in range(100000): if i%2==0: # print(k) k,v = T.query(A,M+1) if k==INF: print(ans) exit() if v==1: ans += 1 T.update(k,(INF,-1)) C[k] -= 1 C[k-A] += 1 T.update(k-A,(k-A,C[k-A])) else: ans += 1 T.update(k,(k,v-1)) C[k] -= 1 C[k-A] += 1 T.update(k-A,(k-A,C[k-A])) else: k,v = T.query(B,M+1) # print(k) if k==INF: print(ans) exit() if v==1: ans += 1 T.update(k,(INF,-1)) C[k] -= 1 C[k-B] += 1 T.update(k-B,(k-B,C[k-B])) else: ans += 1 T.update(k,(k,v-1)) C[k] -= 1 C[k-B] += 1 T.update(k-B,(k-B,C[k-B]))