結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-02-24 21:54:04 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,152 bytes |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 30,720 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-13 05:24:54 |
| 合計ジャッジ時間 | 825 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp_char_arr (const void *a, const void *b) {
return strcmp((char *)a, (char *)b);
}
int main () {
int t = 0;
int n = 0;
char s[1011] = "";
int res = 0;
char ans[1000][1001] = {};
char hw[11] = "helloworld";
res = scanf("%d", &t);
while (t > 0) {
res = scanf("%d", &n);
res = scanf("%s", s);
for (int i = 0; i < n; i++) {
int is_ok = 1;
for (int j = 0; j < 10; j++) {
if (s[i+j] != '?' && s[i+j] != hw[j]) {
is_ok = 0;
}
}
if (is_ok > 0) {
for (int j = 0; j < n; j++) {
if (s[j] == '?') {
ans[i][j] = 'a';
} else {
ans[i][j] = s[j];
}
}
for (int j = 0; j < 10; j++) {
ans[i][i+j] = hw[j];
}
} else {
for (int j = 0; j < n; j++) {
ans[i][j] = '~';
}
}
ans[i][n] = '\0';
}
qsort(ans, n, sizeof(char)*1001, cmp_char_arr);
if (ans[0][0] == '~') {
printf("-1\n");
} else {
printf("%s\n", ans[0]);
}
t--;
}
return 0;
}
chro_96