結果
| 問題 | No.252 "良問"(良問とは言っていない (2) | 
| コンテスト | |
| ユーザー |  fmhr | 
| 提出日時 | 2015-07-25 18:31:45 | 
| 言語 | Go1.4 (1.4.2) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 851 bytes | 
| コンパイル時間 | 356 ms | 
| コンパイル使用メモリ | 33,640 KB | 
| 実行使用メモリ | 15,296 KB | 
| 最終ジャッジ日時 | 2024-11-25 00:22:44 | 
| 合計ジャッジ時間 | 10,911 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 WA * 3 TLE * 2 | 
ソースコード
package main
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
func main() {
	var a int
	a = nextInt()
	for i := 0; i < a; i++ {
		solve()
	}
}
func solve() {
	var s string
	s = next()
	s_len := len(s)
	cost := 100
	p_cost := 0
	for j := 0; j < s_len; j++ {
		if j >= 7 {
			if s[j-7:j] == "problem" {
				p_cost++
			}
		}
		for k := j + 4; k < s_len-6; k++ {
			cost = min(cost, diff(s[j:j+4], "good")+diff(s[k:k+7], "problem")+p_cost)
		}
	}
	fmt.Println(cost)
}
func min(x, y int) int {
	if x > y {
		x = y
	}
	return x
}
func diff(s1, s2 string) int {
	c := 0
	for i := 0; i < len(s1); i++ {
		if s1[i] != s2[i] {
			c++
		}
	}
	return c
}
var s = bufio.NewScanner(os.Stdin)
func next() string {
	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}
func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
            
            
            
        