結果

問題 No.2768 Password Crack
ユーザー 👑 箱星箱星
提出日時 2024-05-31 22:21:35
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 719 ms / 2,000 ms
コード長 1,395 bytes
コンパイル時間 16,076 ms
コンパイル使用メモリ 448,088 KB
実行使用メモリ 83,864 KB
平均クエリ数 1115.47
最終ジャッジ日時 2024-05-31 22:22:11
合計ジャッジ時間 34,959 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 405 ms
79,124 KB
testcase_01 AC 361 ms
79,040 KB
testcase_02 AC 446 ms
79,204 KB
testcase_03 AC 416 ms
79,468 KB
testcase_04 AC 713 ms
82,900 KB
testcase_05 AC 383 ms
78,952 KB
testcase_06 AC 465 ms
79,368 KB
testcase_07 AC 525 ms
79,792 KB
testcase_08 AC 465 ms
79,224 KB
testcase_09 AC 703 ms
82,888 KB
testcase_10 AC 710 ms
83,212 KB
testcase_11 AC 685 ms
83,408 KB
testcase_12 AC 713 ms
82,880 KB
testcase_13 AC 685 ms
82,840 KB
testcase_14 AC 719 ms
83,864 KB
testcase_15 AC 694 ms
83,648 KB
testcase_16 AC 686 ms
82,700 KB
testcase_17 AC 707 ms
83,328 KB
testcase_18 AC 670 ms
83,436 KB
testcase_19 AC 560 ms
79,328 KB
testcase_20 AC 536 ms
79,688 KB
testcase_21 AC 699 ms
83,488 KB
testcase_22 AC 618 ms
83,148 KB
testcase_23 AC 429 ms
79,056 KB
testcase_24 AC 503 ms
79,988 KB
testcase_25 AC 712 ms
83,272 KB
testcase_26 AC 520 ms
80,092 KB
testcase_27 AC 642 ms
82,020 KB
testcase_28 AC 407 ms
79,276 KB
testcase_29 AC 444 ms
79,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*
import kotlin.math.*

fun PrintWriter.solve() {
    val n = nextInt()
    val counter = Array(26) { 0 }
    for (i in 0 until 26) {
        val c = 'a' + i
        val s = "$c".repeat(n)
        println("? $s")
        counter[i] = nextInt()
    }
    var ans = ""
    for (i in 0 until n) {
        val a = Array(26) { 0 }
        for (j in 0 until 26) {
            if (counter[j] == 0) continue
            val s = Array(n) { if (it == i) 'a' + j else 'a' }.joinToString("")
            println("? $s")
            a[j] = nextInt()
        }
        val j = (0 until 26).single { a[it] == a.max() }
        ans += 'a' + j
        counter[j]--
    }
    println("! $ans")
}

fun main() {
    Thread(null, {
        val writer = PrintWriter(System.out, true)
        writer.solve()
        writer.flush()
    }, "solve", abs(1L.shl(26)))
        .apply { setUncaughtExceptionHandler { _, e -> e.printStackTrace(); kotlin.system.exitProcess(1) } }
        .apply { start() }.join()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()
fun nextDouble() = next().toDouble()
// endregion
0