結果

問題 No.150 "良問"(良問とは言っていない
ユーザー 沙耶花
提出日時 2021-11-02 19:37:55
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 620 bytes
コンパイル時間 4,417 ms
コンパイル使用メモリ 250,316 KB
最終ジャッジ日時 2025-01-25 10:26:30
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 s,string t){
	if(s.size()!=t.size())return Inf;
	int ret =0;
	rep(i,s.size()){
		if(s[i]!=t[i])ret++;
	}
	return ret;
}

int main(){	
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		string T;
		cin>>T;
		int ans = Inf;
		rep(i,T.size()){
			for(int j=i+4;j<T.size();j++){
				ans = min(ans,get(T.substr(i,4),"good") + get(T.substr(j,7),"problem"));
			}
		}
		
		cout<<ans<<endl;
		
	}
	
	return 0;
	
}
0