結果
| 問題 |
No.150 "良問"(良問とは言っていない
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-03-22 19:18:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,241 bytes |
| コンパイル時間 | 613 ms |
| コンパイル使用メモリ | 85,508 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-11 02:00:29 |
| 合計ジャッジ時間 | 1,324 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 150.cc: No.150 "良問"(良問とは言っていない - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100;
const int INF = 1 << 30;
const string g = "goodproblem";
const int gn = 11;
/* typedef */
/* global variables */
int dp[MAX_N + 1][gn + 1];
/* subroutines */
/* main */
int main() {
int tn;
cin >> tn;
while (tn--) {
string s;
cin >> s;
int sn = s.size();
for (int i = 0; i <= sn; i++)
for (int j = 0; j <= gn; j++) dp[i][j] = INF;
dp[0][0] = 0;
for (int i = 0; i < sn; i++)
for (int j = 0; j <= gn; j++) {
int d0 = dp[i][j];
if (d0 < INF) {
if (j < gn) {
int d = (s[i] == g[j]) ? d0 : d0 + 1;
if (dp[i + 1][j + 1] > d) dp[i + 1][j + 1] = d;
}
if (j == 0 || j == 4 || j == 11)
if (dp[i + 1][j] > d0) dp[i + 1][j] = d0;
}
}
printf("%d\n", dp[sn][gn]);
}
return 0;
}
tnakao0123