結果

問題 No.2226 Hello, Forgotten World!
ユーザー zezerozezero
提出日時 2023-02-24 22:44:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,149 bytes
コンパイル時間 2,972 ms
コンパイル使用メモリ 158,912 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 06:38:43
合計ジャッジ時間 3,734 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cstring>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
const ll mod = 998244353;

void slove(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  string ans = "{}";
  string h = "helloworld";
  for (int i = n-10; i >= 0;i--){
    string t = s;
    bool can = true;
    for (int j = i; j < i+10;j++){
      if (t[j] == h[j-i]) continue;
      else if (t[j] == '?'){
        t[j] = h[j-i];
        continue;
      } 
      else{
        //cout << "i:" << i << " j:" << j << endl;
        can = false;
        break;
      }
    }
    if (can){
      for (int j = 0; j < n;j++){
        if (t[j] == '?') t[j] = 'a'; 
      }
      //cout << "i:" << i << endl;
      //cout << t << endl;
      ans = min(ans,t);
    }
  }
  if (ans == "{}"){
    cout << -1 << endl;
  }
  else{
    cout << ans << endl;
  }
}
int main(){
  int t;
  cin >> t;
  while(t--){
    slove();
  }
  
  return 0;
}
0