結果
問題 | No.2226 Hello, Forgotten World! |
ユーザー | norikame |
提出日時 | 2022-12-14 12:28:35 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 226 ms / 2,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 3,752 ms |
コンパイル使用メモリ | 74,252 KB |
実行使用メモリ | 59,084 KB |
最終ジャッジ日時 | 2023-09-07 02:39:49 |
合計ジャッジ時間 | 5,214 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
55,908 KB |
testcase_01 | AC | 226 ms
59,084 KB |
testcase_02 | AC | 200 ms
58,028 KB |
testcase_03 | AC | 193 ms
58,484 KB |
testcase_04 | AC | 169 ms
55,684 KB |
testcase_05 | AC | 206 ms
57,936 KB |
testcase_06 | AC | 178 ms
56,396 KB |
testcase_07 | AC | 176 ms
58,184 KB |
testcase_08 | AC | 156 ms
55,724 KB |
testcase_09 | AC | 192 ms
57,828 KB |
ソースコード
// 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(); } }