結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-09-16 00:20:00 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 504 ms |
| コンパイル使用メモリ | 59,768 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 01:56:38 |
| 合計ジャッジ時間 | 1,254 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[]) {
string s;
getline(cin, s);
int T = atoi(s.c_str());
string x = "good", y = "problem";
for (int t = 0; t < T; ++t) {
getline(cin, s);
int len = (int)s.length();
int ans = 1 << 30;
for (int a = x.length(); a <= len - y.length(); ++a) {
int cnt = 0;
for (int b = 0; b < (int)y.length(); ++b) {
cnt += s[a + b] != y[b];
}
for (int b = 0; b <= a - x.length(); ++b) {
int tot = cnt;
for (int c = 0; c < (int)x.length(); ++c) {
tot += s[b + c] != x[c];
}
ans = min(ans, tot);
}
}
cout << ans << endl;
}
return 0;
}
hotpepsi