結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-05 07:34:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 227 ms / 2,000 ms |
| コード長 | 512 bytes |
| コンパイル時間 | 507 ms |
| コンパイル使用メモリ | 67,876 KB |
| 実行使用メモリ | 5,424 KB |
| 最終ジャッジ日時 | 2024-10-14 00:44:51 |
| 合計ジャッジ時間 | 3,050 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#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;
}
}