結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-04-24 02:25:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 550 ms |
| コンパイル使用メモリ | 43,000 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-08 07:08:47 |
| 合計ジャッジ時間 | 1,160 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2226.cc: No.2226 Hello, Forgotten World! - yukicoder
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 1000;
const int L = 10;
const char T[] = "helloworld";
/* typedef */
/* global variables */
char s[MAX_N + 4], t[MAX_N + 4], mins[MAX_N + 4];
/* subroutines */
bool match(char w[]) {
for (int i = 0; i < L; i++)
if (w[i] != '?' && w[i] != T[i]) return false;
return true;
}
/* main */
int main() {
int tn;
scanf("%d", &tn);
while (tn--) {
int n;
scanf("%d%s", &n, s);
bool found = false;
mins[0] = 'z' + 1, mins[1] = '\0';
for (int k = n - L; k >= 0; k--)
if (match(s + k)) {
found = true;
strcpy(t, s);
for (int i = 0; i < L; i++) t[k + i] = T[i];
for (int i = 0; i < n; i++)
if (t[i] == '?') t[i] = 'a';
if (strcmp(mins, t) > 0) strcpy(mins, t);
}
if (found) puts(mins);
else puts("-1");
}
return 0;
}
tnakao0123