結果
| 問題 | No.150 "良問"(良問とは言っていない |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-21 02:33:57 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 4 ms / 5,000 ms |
| + 403µs | |
| コード長 | 613 bytes |
| 記録 | |
| コンパイル時間 | 3,085 ms |
| コンパイル使用メモリ | 177,488 KB |
| 実行使用メモリ | 10,052 KB |
| 最終ジャッジ日時 | 2026-09-21 02:34:07 |
| 合計ジャッジ時間 | 4,573 ms |
|
ジャッジサーバーID (参考情報) |
judge4_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;
string g="good", p="problem";
int f(string s, string& base){
int n=s.size(), ans=0;
for(int i=0; i<n; i++) ans+=(s[i]!=base[i]);
return ans;
}
void solve(){
string s; cin >> s;
int n=s.size();
vector<int> ch(n, 1e9);
for(int i=4; i+6<n; i++){
ch[i]=f(s.substr(i, 7), p);
}
int ans=1e9;
for(int i=0; i+10<n; i++)for(int j=i+4; j+6<n; j++){
ans=min(ans, f(s.substr(i, 4), g)+ch[j]);
}
cout << ans << endl;
}
int main(void){
int t; cin >> t;
while(t--) solve();
return 0;
}