結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-03-31 17:51:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 2,000 ms |
| コード長 | 771 bytes |
| コンパイル時間 | 203 ms |
| コンパイル使用メモリ | 82,308 KB |
| 実行使用メモリ | 57,856 KB |
| 最終ジャッジ日時 | 2024-09-25 12:13:31 |
| 合計ジャッジ時間 | 2,394 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
#!/usr/bin/env python
def main():
sl = list(input().strip())
sw = 0
sw2 = 0
ans = 0
res = 200
tmp = 200
i = 0
while i < len(sl):
s = sl[i]
if sw == 0 and s == 'c':
sw = 1
ans = 1
i += 1
continue
elif s == 'c':
tmp = min(tmp,i)
sw2 = 1
elif sw == 1 and s == 'w':
sw = 2
elif sw == 2 and s == 'w':
ans += 1
res = min(ans, res)
i = tmp if sw2 == 1 else i + 1
tmp = 200
sw = 0
sw2 = 0
continue
ans += 1
i += 1
if res == 200:
print('-1')
else:
print(res)
if __name__ == '__main__':
main()