結果
問題 | No.2768 Password Crack |
ユーザー | tenten |
提出日時 | 2024-06-04 13:56:38 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 250 ms / 2,000 ms |
コード長 | 3,026 bytes |
コンパイル時間 | 2,480 ms |
コンパイル使用メモリ | 80,540 KB |
実行使用メモリ | 57,336 KB |
平均クエリ数 | 583.57 |
最終ジャッジ日時 | 2024-06-04 13:56:49 |
合計ジャッジ時間 | 9,990 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
54,008 KB |
testcase_01 | AC | 80 ms
53,776 KB |
testcase_02 | AC | 123 ms
56,332 KB |
testcase_03 | AC | 99 ms
53,724 KB |
testcase_04 | AC | 236 ms
56,836 KB |
testcase_05 | AC | 91 ms
54,380 KB |
testcase_06 | AC | 107 ms
54,916 KB |
testcase_07 | AC | 106 ms
54,772 KB |
testcase_08 | AC | 130 ms
55,992 KB |
testcase_09 | AC | 238 ms
56,316 KB |
testcase_10 | AC | 238 ms
56,944 KB |
testcase_11 | AC | 229 ms
56,848 KB |
testcase_12 | AC | 233 ms
57,128 KB |
testcase_13 | AC | 250 ms
57,336 KB |
testcase_14 | AC | 237 ms
56,976 KB |
testcase_15 | AC | 233 ms
56,596 KB |
testcase_16 | AC | 228 ms
56,596 KB |
testcase_17 | AC | 242 ms
56,884 KB |
testcase_18 | AC | 224 ms
56,840 KB |
testcase_19 | AC | 174 ms
56,580 KB |
testcase_20 | AC | 157 ms
56,104 KB |
testcase_21 | AC | 226 ms
56,964 KB |
testcase_22 | AC | 193 ms
56,460 KB |
testcase_23 | AC | 96 ms
54,576 KB |
testcase_24 | AC | 139 ms
56,092 KB |
testcase_25 | AC | 227 ms
56,460 KB |
testcase_26 | AC | 154 ms
56,360 KB |
testcase_27 | AC | 209 ms
56,324 KB |
testcase_28 | AC | 107 ms
54,936 KB |
testcase_29 | AC | 112 ms
54,908 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int[] counts = new int[26]; char[] test = new char[n]; for (int i = 0; i < 26; i++) { Arrays.fill(test, (char)('a' + i)); System.out.print("? "); System.out.println(test); System.out.flush(); counts[i] = sc.nextInt(); } int acount = counts[0]; char[] ans = new char[n]; for (int i = 0; i < n; i++) { Arrays.fill(test, 'a'); test[i] = 'b'; System.out.print("? "); System.out.println(test); System.out.flush(); int x = sc.nextInt(); if (x == acount - 1) { ans[i] = 'a'; counts[0]--; continue; } else if (x == acount + 1) { counts[1]--; ans[i] = 'b'; continue; } for (int j = 2; j < 26; j++) { if (counts[j] == 0) { continue; } test[i] = (char)('a' + j); System.out.print("? "); System.out.println(test); System.out.flush(); if (sc.nextInt() == acount + 1) { ans[i] = (char)('a' + j); counts[j]--; break; } } } System.out.print("! "); System.out.println(ans); } static String getString(long x) { if (x == 1) { return ""; } if ((x - 1) % 2 == 0) { String current = getString((x - 1) / 2); if (current != null) { return current + "A"; } } if ((x - 1) % 3 == 0) { String current = getString((x - 1) / 3); if (current != null) { return current + "B"; } } return null; } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }