結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ldsybldsyb
提出日時 2017-07-17 20:23:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 598 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 68,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 09:45:26
合計ジャッジ時間 1,307 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int t;
	cin >> t;
	while(t--){
		string s;
		cin >> s;
		int good_table[s.size() - 3]{}, problem_table[s.size() - 6]{};
		for(int i = 0; i < s.size() - 3; i++) for(int j = 0; j < 4; j++) if(s[i + j] != "good"[j]) good_table[i]++;
		for(int i = 0; i < s.size() - 6; i++) for(int j = 0; j < 7; j++) if(s[i + j] != "problem"[j]) problem_table[i]++;
		int ans = 1e9;
		for(int i = 0; i < s.size() - 3; i++) for(int j = i + 4; j < s.size() - 6; j++) ans = min(ans, good_table[i] + problem_table[j]);
		cout << ans << endl;
	}
}
0