結果
問題 | No.345 最小チワワ問題 |
ユーザー | GrayCoder |
提出日時 | 2017-10-09 16:20:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 479 bytes |
コンパイル時間 | 514 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-25 12:04:07 |
合計ジャッジ時間 | 2,158 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
def main(): S = input() minlen = 101 len_ = 0 for i in range(len(S) - 2): text = '' for j in range(i, len(S)): if S[j] == 'c' and text == '': len_ = 1 text = 'c' elif S[j] == 'w': text = text + 'w' if text == 'cww': minlen = min(minlen, len_) len_ += 1 if minlen == 101: print(-1) else: print(minlen) main()