結果
問題 |
No.150 "良問"(良問とは言っていない
|
ユーザー |
![]() |
提出日時 | 2018-09-14 13:02:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 88 ms / 5,000 ms |
コード長 | 1,507 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 115,944 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 02:14:51 |
合計ジャッジ時間 | 2,088 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <iomanip> #include <array> #include <numeric> #include <regex> #include <bitset> #include <deque> using namespace std; typedef long long ll; typedef pair<int, int> p_ii; const int INF = 1e9; const double PI = acos(-1.0); const ll MOD = 1e9 + 7; int hamdis(string s, string t){ if(s.size()!=t.size())return -1; int cnt=0; for (int i = 0; i < s.size(); i++) { if(s[i]!=t[i])cnt++; } return cnt; } int main() { string g = "good"; string p = "problem"; int n; cin>>n; vector<string>str(n); for (int i = 0; i < n; i++) { cin>>str[i]; } for (int i = 0; i < n; i++) { int res = 1000; string target = str[i]; for (int sg = 0; sg < target.size()-10; sg++) { for (int sp = sg+4; sp < target.size()-6; sp++) { for (int x = 0; x < 4; x++) { target[sg+x]=g[x]; } for (int x = 0; x < 7; x++) { target[sp+x]=p[x]; } res=min(res,hamdis(str[i], target)); target=str[i]; } } cout<<res<<endl; } return 0; }