結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー |
![]() |
提出日時 | 2017-07-17 20:23:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 561 ms |
コンパイル使用メモリ | 68,228 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 02:12:00 |
合計ジャッジ時間 | 1,485 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int main(){ int t; cin >> t; while(t--){ string s; cin >> s; int good_table[s.size() - 3]{}, problem_table[s.size() - 6]{}; for(int i = 0; i < s.size() - 3; i++) for(int j = 0; j < 4; j++) if(s[i + j] != "good"[j]) good_table[i]++; for(int i = 0; i < s.size() - 6; i++) for(int j = 0; j < 7; j++) if(s[i + j] != "problem"[j]) problem_table[i]++; int ans = 1e9; for(int i = 0; i < s.size() - 3; i++) for(int j = i + 4; j < s.size() - 6; j++) ans = min(ans, good_table[i] + problem_table[j]); cout << ans << endl; } }