結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-26 02:45:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 587 bytes |
| コンパイル時間 | 97 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-27 02:40:17 |
| 合計ジャッジ時間 | 2,006 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
import sys
dump = lambda *x : print(*x, file = sys.stderr)
# cawwcww で 4 と返してしまう.
def WA():
import re
s = input()
m = re.search(r'.*c.*w.*w.*?', s)
dump(m)
if m is None:
return(-1)
else:
return(len(m.group(0)))
s = input()
n = len(s)
res = 114514
for i in range(n):
if s[i] != 'c':
continue
cnt = 0
for j in range(i+1,n):
if s[j] == 'w':
cnt += 1
if cnt == 2:
res = min(res, j - i + 1)
break
if res == 114514:
res = -1
print(res)