結果
| 問題 |
No.884 Eat and Add
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2021-03-04 02:00:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 1,000 ms |
| コード長 | 1,560 bytes |
| コンパイル時間 | 135 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 16,316 KB |
| 最終ジャッジ日時 | 2024-10-04 00:48:48 |
| 合計ジャッジ時間 | 1,441 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 |
ソースコード
import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def FI(): return float(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MF(): return map(float, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
inf = 10**16
# md = 998244353
md = 10**9+7
def RLE(s):
cc=[]
ww=[]
pc=s[0]
w=0
for c in s:
if c==pc:w+=1
else:
cc.append(pc)
ww.append(w)
w=1
pc=c
cc.append(pc)
ww.append(w)
return cc,ww
s="000"+SI()
cc,ww=RLE(s)
ans=0
one=False
for w0,w1 in zip(ww[::2],ww[1::2]):
if w0>2:
if w1==1:
ans+=1
one=True
else:
ans+=2
one=False
elif not one and w1==1 and w0==1:
ans+=1
one=False
elif w1==1:
ans+=1
one=True
elif not one and w0==1 and w1>1:
ans+=1
one=False
else:
ans+=2
one=False
print(ans)
mkawa2