結果
問題 |
No.345 最小チワワ問題
|
ユーザー |
![]() |
提出日時 | 2020-01-01 12:20:10 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 107 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 44,104 KB |
最終ジャッジ日時 | 2024-11-21 23:24:56 |
合計ジャッジ時間 | 19,747 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 3 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np S = np.array(list(read().decode('utf-8').rstrip()),'U1') L = len(S) INF = 10 ** 9 left_c = np.full(L,-INF,np.int32) left_c[1:] = np.where(S[:-1] == 'c',np.arange(L-1),-1) np.maximum.accumulate(left_c,out=left_c) L = len(S) right_w = np.full(L,INF,np.int32) right_w[:-1] = np.where(S[1:] == 'w',np.arange(1,L),INF) right_w = np.minimum.accumulate(right_w[::-1])[::-1] right_w#np.maximum.accumulate(left_i,out=left_i) x = right_w - left_c + 1 x[S!='w'] = INF answer = x.min() if answer > L: answer = -1 print(answer)