結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
Nagisa
|
| 提出日時 | 2019-07-26 14:34:27 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 127 ms / 2,000 ms |
| コード長 | 507 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 81,972 KB |
| 実行使用メモリ | 64,096 KB |
| 最終ジャッジ日時 | 2024-07-02 06:27:50 |
| 合計ジャッジ時間 | 2,683 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
S = input()
c = []
w1 = []
w2 = []
for k in range(len(S)):
if S[k] == "c":
c.append(k)
for l in c:
for m in range(l+1,len(S)):
if S[m] == "w":
w1.append(m)
for l in w1:
for m in range(l+1,len(S)):
if S[m] == "w":
w2.append(m)
if len(c) * len(w1) * len(w2) == 0:
print(-1)
else:
ans = 100
for p in c:
for q in w1:
for r in w2:
if p < q < r:
ans = min(ans,r-p+1)
print(ans)
Nagisa