結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
punyfix
|
| 提出日時 | 2017-09-19 16:46:46 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 608 bytes |
| コンパイル時間 | 293 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-11-08 05:36:55 |
| 合計ジャッジ時間 | 2,143 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 8 |
ソースコード
S = input()
c = ""
w = [0,0]
indexw = [i for i, x in enumerate(S) if x == "w"]
indexc = [i for i, x in enumerate(S) if x == "c"]
leng = []
for i in S:
if i == "c":
c = indexc[0]
indexc.pop(0)
w = [0,0]
for i in range(len(indexw)):
if indexw[0] < c:
indexw.pop(0)
else:
break
elif i == "w" and w[0] != 0:
w[1] = indexw[0]
leng.append(w[1]-c+1)
c = 0
elif i == "w" and c != "":
w[0] = indexw[0]
indexw.pop(0)
if len(leng) <= 0:
print(-1)
else:
print(min(leng))
punyfix