結果

問題 No.2226 Hello, Forgotten World!
ユーザー lddlinanlddlinan
提出日時 2023-03-02 13:49:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,332 bytes
コンパイル時間 2,764 ms
コンパイル使用メモリ 84,728 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 10:56:28
合計ジャッジ時間 2,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;


char ib[1024];
int main() {
    int n, i, j;
    const char *p = "helloworld";
    int tc; scanf("%d", &tc); while(tc) { tc--;
        scanf("%d %s", &n, ib);
        for (i=0; i+10<=n; i++) {
            for (j=0; j<10; j++) if (ib[i+j]!=p[j]) break;
            if (j>=10) break;
        }
        if (i+10<=n) {
            for (i=0; i<n; i++) if (ib[i]=='?') ib[i]='a';
            printf("%s\n", ib);
            continue;
        }
        for (i=n-1; i>=9; i--) {
            for (j=0; j<10; j++) {
                if (ib[i-(9-j)]=='?'||ib[i-(9-j)]==p[j]) {
                } else break;
            }
            if (j>=10) {
                for (j=0; j<10; j++) ib[i-(9-j)]=p[j];
                break;
            } 
            if (ib[i]=='?') ib[i]='a';
        }
        if (i>=9) {
            while(i>=0) {
                if (ib[i]=='?') ib[i]='a';
                i--;
            }
            printf("%s\n", ib);
        } else printf("-1\n");
    }
    return 0;
}
0