結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
6soukiti29
|
| 提出日時 | 2017-09-18 12:59:56 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 852 bytes |
| コンパイル時間 | 3,189 ms |
| コンパイル使用メモリ | 65,724 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 03:12:39 |
| 合計ジャッジ時間 | 3,782 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'sequtils' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
import sequtils,strutils,math,algorithm
type
item = tuple[index,cost : int]
var
T = stdin.readline.parseInt
s : string
g = "good"
p = "problem"
for t in 1..T:
s = stdin.readline
var
a : item
cnt : int
A = newSeq[item](0)
ans : int = int.high
for i in 0..(s.high - 6):
cnt = 0
for j in 0..p.high:
if s[i + j] != p[j]:
cnt += 1
a = (i, cnt)
A.add(a)
A = A.sortedByIt(it.cost)
for i in 0..(s.high - 3):
cnt = 0
for j in 0..g.high:
if s[i + j] != g[j]:
cnt += 1
var flag : bool
for a in A:
if a.index > i + 3:
cnt += a.cost
flag = true
break
if flag:
ans = min(ans, cnt)
echo ans
6soukiti29