結果

問題 No.150 "良問"(良問とは言っていない
ユーザー tanimani364tanimani364
提出日時 2021-03-23 18:33:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 717 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,664 KB
最終ジャッジ日時 2024-05-04 03:31:58
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
77,712 KB
testcase_01 AC 50 ms
64,000 KB
testcase_02 AC 49 ms
64,128 KB
testcase_03 AC 48 ms
63,872 KB
testcase_04 AC 49 ms
63,744 KB
testcase_05 AC 62 ms
71,424 KB
testcase_06 AC 135 ms
78,664 KB
testcase_07 AC 50 ms
64,128 KB
testcase_08 AC 61 ms
67,712 KB
testcase_09 AC 52 ms
64,640 KB
testcase_10 AC 109 ms
77,696 KB
testcase_11 AC 116 ms
77,792 KB
testcase_12 AC 117 ms
77,568 KB
testcase_13 AC 127 ms
77,752 KB
testcase_14 AC 136 ms
78,060 KB
testcase_15 AC 125 ms
77,892 KB
testcase_16 AC 82 ms
77,664 KB
testcase_17 AC 96 ms
77,312 KB
testcase_18 AC 123 ms
78,336 KB
testcase_19 AC 124 ms
77,824 KB
testcase_20 AC 142 ms
78,208 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