結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー |
![]() |
提出日時 | 2020-07-09 22:15:14 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 785 bytes |
コンパイル時間 | 2,830 ms |
コンパイル使用メモリ | 193,124 KB |
最終ジャッジ日時 | 2025-01-11 17:16:02 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair<int,int> P; const string good = "good"; const string problem = "problem"; constexpr int INF = 2e9; int main() { int t; cin >> t; while (t--) { string s; cin >> s; int n = s.size(); int res = INF; for (int i = 0; i <= n - 11; i++) { int add1 = 0; for (int j = 0; j < 4; j++) add1 += (s[i + j] != good[j]); for (int j = i + 4; j <= n - 7; j++) { int add2 = 0; for (int k = 0; k < 7; k++) add2 += (s[j + k] != problem[k]); res = min(res, add1 + add2); } } //cout << "ans "; cout << res << endl; } return 0; }