結果
問題 | No.345 最小チワワ問題 |
ユーザー |
|
提出日時 | 2016-03-26 12:14:01 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 724 bytes |
コンパイル時間 | 77 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-25 11:41:37 |
合計ジャッジ時間 | 1,857 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
def checkChiwawaLen(strin,startPos): first = strin.find("w",startPos) second = strin.find("w",first + 1) if first == -1 or second == -1: return -1 else: return second - startPos + 1 def getCharPositionList(strin,char): startPos = 0 result = [] while(True): targetPos = strin.find(char,startPos) if targetPos == -1: break result.append(targetPos) startPos = targetPos + 1 return result #inputLine = "chiwawacchichiwawac" inputLine = input() posList = getCharPositionList(inputLine,"c") result = [s for s in [checkChiwawaLen(inputLine,s) for s in posList] if s != -1] if len(result) != 0: print(min(result)) else: print(-1)