結果

問題 No.345 最小チワワ問題
コンテスト
ユーザー Noiri
提出日時 2019-03-16 13:15:25
言語 Go
(1.26.1)
コンパイル:
env GOCACHE=/tmp go build _filename_
実行:
./Main
結果
WA  
実行時間 -
コード長 365 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,592 ms
コンパイル使用メモリ 289,772 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-23 01:34:20
合計ジャッジ時間 12,441 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 12 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 index == -1 {
			break
		}

		s = s[index:]
		res := r.FindString(s)

		if ans < 0 || len(res) < ans {
			ans = len(res)
		}

		s = s[1:]
	}
	fmt.Println(ans)
}
0