結果

問題 No.150 "良問"(良問とは言っていない
ユーザー nksk38nksk38
提出日時 2017-07-15 13:48:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,143 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 84,252 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 21:46:21
合計ジャッジ時間 1,550 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, string> pls;

int main()
{
	int T; cin >> T;
	vector<int> v;
	string problem = "problem",good = "good";

	for (int i = 0; i < T; i++) {
		string s; cin >> s;
		int mx_p = 0,mx_g = 0,ind = 4;
		for (int k = 4; k < s.size()-6; k++) {
			string str = s.substr(k,7);
			int cnt = 0;

			for (int j = 0; j < str.size(); j++) {
				if (problem[j] == str[j])cnt++;
			}
			if (mx_p <= cnt) {
				mx_p = cnt;
				ind = k;
			}
		}
		for (int k = 0; k < ind-3; k++) {
			string str = s.substr(k,4);
			int cnt = 0;
			for (int j = 0; j < str.size(); j++) {
				if (good[j] == str[j])cnt++;
			}
			mx_g = max(mx_g,cnt);
		}
		v.push_back(11 - mx_p - mx_g);
	}

	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}
	return 0;
}
0