結果

問題 No.150 "良問"(良問とは言っていない
ユーザー nksk38nksk38
提出日時 2017-07-15 15:20:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 988 bytes
コンパイル時間 779 ms
コンパイル使用メモリ 75,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 10:14:12
合計ジャッジ時間 1,588 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 3 ms
4,384 KB
testcase_20 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:33:13: warning: overflow in conversion from ‘long int’ to ‘int’ changes value from ‘10000000000’ to ‘1410065408’ [-Woverflow]
   int ans = 10000000000;
             ^~~~~~~~~~~

ソースコード

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;
	string problem = "problem";
	string good = "good";

	for (int t = 0; t < T; t++) {
		string s;
		cin >> s;
		int ans = 10000000000;

		for (int i = 0; i <= s.size() - 4 - 7; i++) {
			int res1 = 0;
			for (int k = 0; k < good.size(); k++) {
				if (s[i + k] != good[k])res1++;
			}
			for (int j = i + 4; j <= s.size() - 7; j++) {
				int res2 = 0;
				for (int k = 0; k < problem.size(); k++) {
					if (s[j + k] != problem[k])
						res2++;
				}
				ans = min(ans, res1 + res2);
			}
		}
		cout << ans << endl;
	}
	return 0;
}
0