結果
| 問題 | No.150 "良問"(良問とは言っていない |
| コンテスト | |
| ユーザー |
くれちー
|
| 提出日時 | 2017-02-06 20:42:49 |
| 言語 | C90(gcc15) (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 642 bytes |
| 記録 | |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 38,988 KB |
| 最終ジャッジ日時 | 2026-02-24 00:16:59 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <stdio.h>
#include <string.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define min(a, b) (a < b ? a : b)
#define inf 1145141919
int main() {
char *good = "good";
char *problem = "problem";
int i, j, t;
scanf("%d", &t);
rep(i, t) {
char s[101];
scanf("%s", s);
int len = strlen(s);
int top1 = 0, top2 = len - 7;
int ans = inf;
while (top1 <= len - 11) {
int t1 = 0, t2 = 0;
rep(j, 4) if (s[top1 + j] != good[j]) t1++;
rep(j, 7) if (s[top2 + j] != problem[j]) t2++;
ans = min(ans, t1 + t2);
if (top1 + 4 == top2) { top1++; top2 = len - 7; }
else top2--;
}
printf("%d\n", ans);
}
return 0;
}
くれちー