結果
問題 | No.150 "良問"(良問とは言っていない |
ユーザー |
![]() |
提出日時 | 2015-06-14 15:46:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 1,154 bytes |
コンパイル時間 | 1,240 ms |
コンパイル使用メモリ | 159,220 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 01:55:21 |
合計ジャッジ時間 | 1,953 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> int main() { int N; int diff_g[128]; int diff_p[128]; int ans; std::string str; int count; std::cin >> N; for(int i = 0; i < N; ++i) { std::cin >> str; for(int j = 0; j < 128; ++j) { diff_g[j] = 10000; diff_p[j] = 10000; } for(int j = 0; j <= str.size()-4; ++j) { count = 0; if( str[j] != 'g' ) count += 1; if( str[j+1] != 'o' ) count += 1; if( str[j+2] != 'o' ) count += 1; if( str[j+3] != 'd' ) count += 1; diff_g[j] = count; } for(int j = 0; j <= str.size()-7; ++j) { count = 0; if( str[j] != 'p' ) count += 1; if( str[j+1] != 'r' ) count += 1; if( str[j+2] != 'o' ) count += 1; if( str[j+3] != 'b' ) count += 1; if( str[j+4] != 'l' ) count += 1; if( str[j+5] != 'e' ) count += 1; if( str[j+6] != 'm' ) count += 1; diff_p[j] = count; } ans = 10000; for(int j = 0; j <= str.size()-4-7; ++j) { for(int k = j+4; k <= str.size()-7; ++k) { ans = std::min(ans, diff_g[j]+diff_p[k]); } } std::cout << ans << std::endl; } return 0; }