結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 07:34:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 68,464 KB
実行使用メモリ 5,552 KB
最終ジャッジ日時 2024-04-22 02:04:33
合計ジャッジ時間 2,434 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
5,248 KB
testcase_01 AC 130 ms
5,376 KB
testcase_02 AC 121 ms
5,376 KB
testcase_03 AC 124 ms
5,420 KB
testcase_04 AC 123 ms
5,420 KB
testcase_05 AC 126 ms
5,552 KB
testcase_06 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int T;
string s;
main()
{
	cin>>T;
	for(;T--;)
	{
		cin>>s;
		int ans=1e9,cummin=1e9,pc=0;
		for(int i=0;i+6<s.size();i++)
		{
			int cnt=0;
			for(int j=0;j<7;j++)cnt+=s[i+j]!="problem"[j];
			ans=min(ans,cummin+cnt+pc);
			if(cnt==0)pc++;
			if(i>=3)
			{
				int now=0;
				for(int j=0;j<4;j++)now+=s[i-3+j]!="good"[j];
				for(int j=i-9;j<=i;j++)if(j>=0&&s.substr(j,7)=="problem")now--;
				cummin=min(cummin,now);
			}
		}
		cout<<ans<<endl;
	}
}
0