結果
| 問題 |
No.345 最小チワワ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-03-16 13:27:47 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 378 bytes |
| コンパイル時間 | 12,091 ms |
| コンパイル使用メモリ | 230,972 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 05:14:40 |
| 合計ジャッジ時間 | 12,609 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 29 |
ソースコード
package main
import (
"fmt"
"regexp"
"strings"
)
func main(){
var s string
fmt.Scan(&s)
r := regexp.MustCompile(`c[^w]*w[^w]*w`)
var ans int = -1
for {
index := strings.Index(s, "c")
if r.MatchString(s) == false {
break
}
s = s[index:]
res := r.FindString(s)
if ans < 0 || len(res) < ans {
ans = len(res)
}
s = s[1:]
}
fmt.Println(ans)
}