結果

問題 No.252 "良問"(良問とは言っていない (2)
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 07:49:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 582 ms
コンパイル使用メモリ 68,352 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-22 02:04:44
合計ジャッジ時間 1,405 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int T;
string s;
bool pf[1<<20];
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(pf[i]=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&&pf[j])now--;
				cummin=min(cummin,now);
			}
		}
		cout<<ans<<endl;
	}
}
0