結果

問題 No.342 一番ワロタww
ユーザー Nagisa
提出日時 2016-02-13 07:42:57
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 1,027 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-15 13:20:20
合計ジャッジ時間 1,411 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
S = str(input())

ans = 0
temp = 0
st = 0
while S[st] == "w":
    st += 1
    if st == len(S):
        break
for k in range(st,len(S)):
    if S[k] == "w" and S[k-1] != "w":
        temp = 1
    elif S[k] == S[k-1] == "w":
        temp += 1
    else:
        temp = 0
    ans = max(ans,temp)

if ans == 0:
    print("")
    exit()

kotae = []
S = S[::-1]

if S[0] == "w":
    temp = 1
else:
    temp = 0
for k in range(1,len(S)):
    if S[k] == "w" and S[k-1] == "w":
        temp += 1
    elif S[k] != "w" and S[k-1] == "w" and temp == ans:
        st = k
        ed = k+1
    elif S[k] != "w" and S[k-1] != "w" and temp == ans:
        ed += 1
    elif S[k] == "w" and S[k-1] != "w" and temp == ans:
        kotae.append(S[st:ed])
        temp = 1
    elif S[k] == "w" and S[k-1] != "w":
        temp = 1
if temp == ans and S[len(S)-1] != "w":
    kotae.append(S[st:ed])


kotae = reversed(kotae)
if kotae:
    for words in kotae:
        print(words[::-1])
else:
    print("")
0