結果

問題 No.150 "良問"(良問とは言っていない
ユーザー tanimani364tanimani364
提出日時 2021-03-23 18:33:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 245 ms / 5,000 ms
コード長 717 bytes
コンパイル時間 936 ms
コンパイル使用メモリ 87,100 KB
実行使用メモリ 82,624 KB
最終ジャッジ日時 2023-08-16 20:07:05
合計ジャッジ時間 6,120 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 202 ms
82,480 KB
testcase_01 AC 141 ms
79,800 KB
testcase_02 AC 143 ms
79,532 KB
testcase_03 AC 140 ms
79,776 KB
testcase_04 AC 143 ms
79,760 KB
testcase_05 AC 156 ms
80,692 KB
testcase_06 AC 226 ms
82,444 KB
testcase_07 AC 139 ms
79,800 KB
testcase_08 AC 144 ms
80,756 KB
testcase_09 AC 142 ms
79,844 KB
testcase_10 AC 208 ms
82,276 KB
testcase_11 AC 203 ms
82,268 KB
testcase_12 AC 203 ms
82,416 KB
testcase_13 AC 213 ms
82,520 KB
testcase_14 AC 227 ms
82,624 KB
testcase_15 AC 216 ms
82,244 KB
testcase_16 AC 164 ms
81,124 KB
testcase_17 AC 188 ms
82,144 KB
testcase_18 AC 226 ms
82,416 KB
testcase_19 AC 225 ms
82,568 KB
testcase_20 AC 245 ms
82,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
#coding:utf-8

import math
import string
from sys import stdin
# import numpy as np
# from matplotlib import pyplot as plt

	
def main():
	read=stdin.readline

	#edit here!
	t=int(read())
	while t>0:
		t-=1
		s=read()
		n=len(s)
		n-=1

		ans=n

		good=lambda a,b,c,d:(a!='g')+(b!='o')+(c!='o')+(d!='d')
		problem=lambda a,b,c,d,e,f,g:(a!='p')+(b!='r')+(c!='o')+(d!='b')+(e!='l')+(f!='e')+(g!='m')
		for i in range(n-10):
			res=0
			res+=good(s[i],s[i+1],s[i+2],s[i+3])

			minv=n
			for j in range(n-i-10):
				minv=min(minv,problem(s[i+4+j],s[i+4+j+1],s[i+4+j+2],s[i+4+j+3],s[i+4+j+4],s[i+4+j+5],s[i+4+j+6]))

			res+=minv
			ans=min(ans,res)
		print(ans)
if __name__ == '__main__':
	main()
0