結果
| 問題 |
No.3011 あ、俺こいつの役やりたい!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-01 19:26:21 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 3,517 bytes |
| コンパイル時間 | 21,312 ms |
| コンパイル使用メモリ | 492,872 KB |
| 実行使用メモリ | 76,096 KB |
| 平均クエリ数 | 13.43 |
| 最終ジャッジ日時 | 2025-02-01 19:27:08 |
| 合計ジャッジ時間 | 43,054 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 RE * 40 |
ソースコード
import java.io.InputStream
import java.io.PrintStream
val reader = FastReader()
val writer = FastWriter()
fun main() {
writer.append((1..1_000_000_000).findN(30)).println()
}
fun IntRange.findN(M: Int): Int {
var min = this.start
var max = this.last
for (i in 0 until M - 1) {
val mid = min + (max - min) / 2
writer.append(mid).println()
val ans = reader.readInt()
when (ans) {
1 -> min = mid
0 -> max = mid - 1
}
}
return min
}
class FastReader(private val stream: InputStream = System.`in`) {
private val buffer = ByteArray(1024 * 16)
private var size = 0
private var pos = 0
private var isEnded = false
private fun checkAndReplenishment() {
if (isEnded || size > pos) return
size = stream.read(buffer, 0, buffer.size)
pos = 0
if (size < 0) isEnded = true
}
fun readByte(): Byte {
checkAndReplenishment()
return buffer[pos++]
}
fun read(): String {
val bytes = mutableListOf<Byte>()
while (true) {
val byte = readByte()
if (byte == SPACE || byte == LINE_FEED) break
bytes.add(byte)
}
return bytes.toByteArray().toString(Charsets.UTF_8)
}
fun readLine(): String {
val bytes = mutableListOf<Byte>()
while (true) {
val byte = readByte()
if (byte == LINE_FEED) break
bytes.add(byte)
}
return bytes.toByteArray().toString(Charsets.UTF_8)
}
fun skip(i: Int = 1): FastReader {
repeat(i) {
while (readByte() != LINE_FEED) {}
}
return this
}
fun readChar(): Char = read()[0]
fun readInt(): Int = read().toInt()
fun readLong(): Long = read().toLong()
fun readFloat(): Float = read().toFloat()
fun readDouble(): Double = read().toDouble()
fun readBoolean(): Boolean = read().toBoolean()
fun readList(): List<String> = readLine().split(" ")
fun readChars(): List<Char> = readLine().split(" ").map { it[0] }
fun readInts(): List<Int> = readLine().split(" ").map { it.toInt() }
fun readInts(adjust: Int): List<Int> = readLine().split(" ").map { it.toInt() + adjust }
fun readLongs(): List<Long> = readLine().split(" ").map { it.toLong() }
fun readLongs(adjust: Long): List<Long> = readLine().split(" ").map { it.toLong() + adjust }
fun readFloats(): List<Float> = readLine().split(" ").map { it.toFloat() }
fun readDoubles(): List<Double> = readLine().split(" ").map { it.toDouble() }
fun readBooleans(): List<Boolean> = readLine().split(" ").map { it.toBoolean() }
companion object {
private const val SPACE = ' '.code.toByte()
private const val LINE_FEED = '\n'.code.toByte()
}
}
class FastWriter(private val stream: PrintStream = System.out, private val capacity: Int = 1024 * 1024 * 8) {
private val writeText = StringBuilder()
fun append(any: Any? = ""): FastWriter {
writeText.append(any)
checkCapacity()
return this
}
fun appendLine(any: Any? = ""): FastWriter {
writeText.appendLine(any)
checkCapacity()
return this
}
fun print() {
stream.print(writeText)
writeText.clear()
}
fun println() {
stream.println(writeText)
writeText.clear()
}
private fun checkCapacity() {
if (writeText.length > capacity) print()
}
}