結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-29 19:24:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 2,000 ms |
| コード長 | 425 bytes |
| コンパイル時間 | 211 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-25 12:13:40 |
| 合計ジャッジ時間 | 2,011 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
string = input()
c_indices = [i for i, x in enumerate(string) if string[i] == "c"]
w_indices = [i for i, x in enumerate(string) if string[i] == "w"]
length = 1000
for c_index in c_indices:
for i, w_index in enumerate(w_indices[:-1]):
if c_index < w_index:
ww_index = w_indices[i + 1]
length = min(length, ww_index - c_index + 1)
if length == 1000:
print(-1)
else:
print(length)