結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2024-12-27 15:23:17 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 765 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-12-27 15:23:20 |
合計ジャッジ時間 | 2,256 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 6 |
ソースコード
S = str(input()) chiwawa_index_dict = {"c": 0, "first_w": 0, "second_w": 0} has_filled_c = False has_filled_first_w = False has_filled_second_w = False for i, word in enumerate(S): if word == "c" and not has_filled_c: chiwawa_index_dict["c"] = i has_filled_c = True elif word == "c" and has_filled_c and not has_filled_first_w: chiwawa_index_dict["c"] = i elif word == "w" and has_filled_c and not has_filled_first_w: chiwawa_index_dict["first_w"] = i has_filled_first_w = True elif word == "w" and has_filled_c and has_filled_first_w and not has_filled_second_w: chiwawa_index_dict["second_w"] = i has_filled_second_w = True break if has_filled_second_w: print(chiwawa_index_dict["second_w"] - chiwawa_index_dict["c"] + 1) else: print(-1)