結果
| 問題 |
No.252 "良問"(良問とは言っていない (2)
|
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2016-02-25 18:12:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,035 bytes |
| コンパイル時間 | 1,293 ms |
| コンパイル使用メモリ | 161,948 KB |
| 実行使用メモリ | 12,196 KB |
| 最終ジャッジ日時 | 2024-09-22 13:42:42 |
| 合計ジャッジ時間 | 2,181 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 5 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:32: warning: use of an operand of type ‘bool’ in ‘operator++’ is deprecated [-Wdeprecated]
29 | if(unmatch[1][i] == 0) ++flag;
| ^~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
const string temp[] = {"good", "problem"};
int unmatch[2][1000000];
int main()
{
int K;
cin >> K;
while(K--) {
string S;
cin >> S;
for(int j = 0; j < 2; j++) {
for(int i = 0; i <= S.size() - temp[j].size(); i++) {
unmatch[j][i] = 0;
for(int k = 0; k < temp[j].size(); k++) {
unmatch[j][i] += S[i + k] != temp[j][k];
}
}
}
for(int i = 1; i <= S.size() - temp[0].size(); i++) {
unmatch[0][i] = min(unmatch[0][i - 1], unmatch[0][i]);
}
int add = 0;
for(int i = S.size() - temp[1].size() - 1; i >= 0; i--) {
bool flag = false;
if(unmatch[1][i] == 0) ++flag;
unmatch[1][i] = min(unmatch[1][i + 1], unmatch[1][i] + add);
add += flag;
}
int ret = INF;
for(int i = 0; i + temp[0].size() <= S.size() - temp[1].size() ; i++) {
ret = min(ret, unmatch[0][i] + unmatch[1][i + temp[0].size()] + add);
}
cout << ret << endl;
}
}
ei1333333