結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー 唐澤貴洋唐澤貴洋
提出日時 2015-10-15 19:21:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 987 bytes
コンパイル時間 992 ms
コンパイル使用メモリ 70,160 KB
実行使用メモリ 15,888 KB
最終ジャッジ日時 2023-09-28 21:49:17
合計ジャッジ時間 2,148 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
7,448 KB
testcase_01 AC 88 ms
7,484 KB
testcase_02 AC 51 ms
12,500 KB
testcase_03 AC 55 ms
15,888 KB
testcase_04 AC 55 ms
15,840 KB
testcase_05 AC 55 ms
15,828 KB
testcase_06 AC 2 ms
7,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<bitset>
#include<array>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstdlib>
#include<numeric>
#define D int
#define U unsigned
using namespace std;
D n, m,a, b, d, e, x, y, z;
D i, j, k;
char c,f;
string s;
bool f1;
D p[1000001],q[1000001],r[1000001];
int main() {
	cin >> a;
	D t;
	for (i = 0; i < a; i++) {
		cin >> s;
		t=s.size();
		for (j = 0; j <= t - 7; j++) {
			p[j] = 0;
			for (k = 0; k < 7; k++) {
				if (s[j + k] != "problem"[k])
					p[j]++;
			}
			r[j] = r[j - 1];
			if (!p[j])
				r[j]++;
		}
		for (j = t - 8; j >= 0; j--) {
			p[j] = min(p[j], p[j + 1]);
		}
		for (j = 0; j <= t-11; j++) {
			q[j] = 0;
			for (k = 0; k < 4; k++) {
				if (s[j + k] != "good"[k])
					q[j]++;
			}
			if(j>=7)
				q[j] += r[j-7];
		}
		n = q[0]+p[4];
		for (j = 1; j <= t - 11; j++) {
			n=min(n, q[j]+p[j + 4]);
		}
		cout << n << endl;
	}
}
0