結果

問題 No.436 ccw
コンテスト
ユーザー rlangevin
提出日時 2024-08-05 12:54:55
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 72 ms / 2,000 ms
+ 548µs
コード長 546 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 271 ms
コンパイル使用メモリ 96,104 KB
実行使用メモリ 83,200 KB
最終ジャッジ日時 2026-08-24 21:07:21
合計ジャッジ時間 3,713 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

S = input()
N = len(S)
cnt = 0
for i in range(N - 2):
    if S[i] == "c" and S[i+1] == "c" and S[i+2] == "w":
        cnt += 1

if cnt == 0:
    print(0)
    exit()
    
ans = 10 ** 18
c = 0
for i in range(N - 2):
    if S[i] == "c" and S[i+1] == "c" and S[i+2] == "w":
        c += 1
        if c == cnt:
            ans = min(ans, i + 1)
            
c = 0
for i in range(N - 1, 1, -1):
    if S[i] == "w" and S[i-1] == "c" and S[i-2] == "c":
        c += 1
        if c == cnt:
            ans = min(ans, N - i)
            
print(ans)        
0