結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-03-22 22:19:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 2,000 ms |
| コード長 | 862 bytes |
| コンパイル時間 | 3,908 ms |
| コンパイル使用メモリ | 252,788 KB |
| 最終ジャッジ日時 | 2025-01-28 11:00:55 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define Inf 1000000001
int get(string x,string y){
if(x.size()!=y.size())return Inf;
int ret= 0;
rep(i,x.size()){
if(x[i]!=y[i])ret++;
}
return ret;
}
int main(){
int _t;
cin>>_t;
rep(_,_t){
string s;
cin>>s;
int n = s.size();
vector dp(n+1,vector<int>(2,Inf));
dp[0][0] = 0;
int ans = Inf;
rep(i,n){
{
int cc = 0;
if(s.substr(i,7)=="problem")cc = 1;
dp[i+1][0] = min(dp[i+1][0],dp[i][0]+cc);
}
if(i+4<=n){
dp[i+4][1] = min(dp[i+4][1], dp[i][0] + get(s.substr(i,4), "good"));
}
dp[i+1][1] = min(dp[i+1][1],dp[i][1]);
ans = min(ans,dp[i][1] + get(s.substr(i,7), "problem"));
}
cout<<ans<<endl;
}
return 0;
}
沙耶花