結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-10-03 20:19:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 549 ms / 2,000 ms |
| コード長 | 943 bytes |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 124,624 KB |
| 最終ジャッジ日時 | 2024-07-26 14:10:10 |
| 合計ジャッジ時間 | 4,511 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
ソースコード
import sys
input = sys.stdin.readline
M = int(input())
for _ in range(M):
S = list(input())
N = len(S)
T = [0] * 8
problem = "problem"
for i in range(4, N - 7):
cnt = 0
for j in range(7):
cnt += int(S[i + j] != problem[j])
T[cnt] += 1
ans = 10 ** 18
good = "good"
problem_cnt = 0
for i in range(N - 11):
cnt = problem_cnt
for j in range(4):
cnt += int(S[i + j] != good[j])
temp = 10 ** 18
for j in range(8):
if T[j]:
temp = j
break
ans = min(ans, cnt + temp)
cnt = 0
for j in range(7):
if i + 4 + j >= N:
break
cnt += int(S[i + 4 + j] != problem[j])
T[cnt] -= 1
if i >= 6:
if S[i-6:i+1] == list(problem):
problem_cnt += 1
print(ans)
rlangevin