제출 #886041

#제출 시각아이디문제언어결과실행 시간메모리
886041CDuongSum Zero (RMI20_sumzero)C++17
컴파일 에러
0 ms0 KiB
import kotlin.math.* import java.util.Vector private fun readLn() = readLine()!! private fun readInt() = readLn().toInt() private fun readLong() = readLn().toLong() private fun readStrings() = readLn().split(" ") private fun readInts() = readStrings().map { it.toInt() } private fun readLongs() = readStrings().map { it.toLong() } fun main() { var n = readInt() var a = readInts() var i: Int = 0 i = 1 var cope = Array(6) { 1 } while (i < 6) { cope[i] = cope[i - 1] * 10 i++ } var nxt = Array(6) { Array<Int>(n + 2) { n + 1 } } var mp = mutableMapOf<Long, Int>() mp[0] = 0 i = 0 var cur_sum: Long = 0 while (i < n) { cur_sum += a[i] if (mp[cur_sum] != null) { // println(mp[cur_sum]) nxt[0][mp[cur_sum]!!] = i + 1 } mp[cur_sum] = i + 1; i++; } i = n; while (i >= 0) { nxt[0][i] = min(nxt[0][i], nxt[0][i + 1]) i-- } i = 1 var j = 0 while (i < 6) { j = 0 while (j < n) { nxt[i][j] = nxt[i - 1][nxt[i - 1][nxt[i - 1][nxt[i - 1][nxt[i - 1][j]]]]] // println("${i}, ${j}, ${nxt[i][j]}") j++ } i++; } var q = readInt() repeat(q) { var (l, r) = readInts() l-- var res = 0 i = 5 while (i >= 0 && l < n) { while (nxt[i][l] <= r) { res += cope[i] l = nxt[i][l] } i-- } println(res) } // i = 0 // while (i < n) { // println(nxt[0][i]) // i++ // } }

컴파일 시 표준 에러 (stderr) 메시지

sumzero.cpp:1:1: error: 'import' does not name a type
    1 | import kotlin.math.*
      | ^~~~~~
sumzero.cpp:9:1: error: expected unqualified-id before 'private'
    9 | private fun readLongs() = readStrings().map { it.toLong() }
      | ^~~~~~~
sumzero.cpp:11:1: error: 'fun' does not name a type
   11 | fun main() {
      | ^~~