結果
| 問題 |
No.2226 Hello, Forgotten World!
|
| コンテスト | |
| ユーザー |
norikame
|
| 提出日時 | 2022-12-14 12:28:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 224 ms / 2,000 ms |
| コード長 | 987 bytes |
| コンパイル時間 | 1,939 ms |
| コンパイル使用メモリ | 77,696 KB |
| 実行使用メモリ | 57,464 KB |
| 最終ジャッジ日時 | 2024-06-24 21:22:26 |
| 合計ジャッジ時間 | 4,348 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 9 |
ソースコード
//
import java.util.*;
public class Main {
private static final String TAR = "helloworld";
public static void main(String[] args) {
final int TLEN = TAR.length();
Scanner sc = new Scanner(System.in);
int t0 = sc.nextInt();
for (int i0=0; i0<t0; ++i0) {
int n = sc.nextInt();
String s = sc.next(), res = "";
for (int i=0; i+TLEN-1<n; ++i) {
boolean ok = true;
for (int j=0; j<TLEN; ++j) if (s.charAt(i+j)!='?' && s.charAt(i+j)!=TAR.charAt(j)) {
ok = false;
break;
}
if (!ok) continue;
String ts = new StringBuilder(s).replace(i, i+TLEN, TAR).toString().replace('?', 'a');
if (res.isEmpty() || ts.compareTo(res)<0) res = ts;
}
if (res.isEmpty()) System.out.println(-1);
else System.out.println(res);
}
sc.close();
}
}
norikame