提出 #42944526


ソースコード 拡げる

fun main() {
    val (ha, wa) = readLine()!!.split(" ").map { it.toInt() }
    val a = List(ha) {
        readLine()!!.toCharArray()
    }

    val (hb, wb) = readLine()!!.split(" ").map { it.toInt() }
    val b = List(hb) {
        readLine()!!.toCharArray()
    }

    val (hx, wx) = readLine()!!.split(" ").map { it.toInt() }
    val x = List(hx) {
        readLine()!!.toCharArray()
    }

    val normalizedA = normalize(blackPositionSet(a))
    val normalizedB = normalize(blackPositionSet(b))
    val normalizedX = normalize(blackPositionSet(x))

    for(i in -hx..hx) {
        for(j in -wx..wx) {
            val set = normalizedA + normalizedB.map { it.first + i to it.second + j }
            if(normalize(set) == normalizedX) {
                println("Yes")
                return
            }
        }
    }

    println("No")
}

fun blackPositionSet(s: List<CharArray>): MutableSet<Pair<Int, Int>> {
    val set = mutableSetOf<Pair<Int, Int>>()
    for(i in s.indices) {
        for(j in s.first().indices) {
            if(s[i][j] == '#') {
                set.add(i to j)
            }
        }
    }
    return set
}

fun normalize(s: Set<Pair<Int, Int>>): Set<Pair<Int, Int>> {
    val dy = s.map { it.first }.min()!!
    val dx = s.map { it.second }.min()!!

    return s.map { it.first - dy to it.second - dx }.toSet()
}

提出情報

提出日時
問題 C - Ideal Sheet
ユーザ dhirabayashi
言語 Kotlin (1.3.71)
得点 300
コード長 1396 Byte
結果 AC
実行時間 206 ms
メモリ 45536 KiB

コンパイルエラー

warning: ATTENTION!
This build uses unsafe internal compiler arguments:

-XXLanguage:+InlineClasses

This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!

Main.kt:2:14: warning: variable 'wa' is never used
    val (ha, wa) = readLine()!!.split(" ").map { it.toInt() }
             ^
Main.kt:7:14: warning: variable 'wb' is never used
    val (hb, wb) = readLine()!!.split(" ").map { it.toInt() }
             ^

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 4
AC × 32
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt, example_03.txt
All example_00.txt, example_01.txt, example_02.txt, example_03.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, random2_00.txt, random2_01.txt, random2_02.txt, random2_03.txt, random2_04.txt, random2_05.txt, random2_06.txt, random2_07.txt, random2_08.txt, random2_09.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 119 ms 36724 KiB
example_01.txt AC 109 ms 36720 KiB
example_02.txt AC 96 ms 36572 KiB
example_03.txt AC 112 ms 36652 KiB
hand_00.txt AC 206 ms 45536 KiB
hand_01.txt AC 109 ms 36740 KiB
hand_02.txt AC 112 ms 36748 KiB
hand_03.txt AC 134 ms 38048 KiB
hand_04.txt AC 178 ms 42232 KiB
hand_05.txt AC 107 ms 36752 KiB
hand_06.txt AC 107 ms 36640 KiB
hand_07.txt AC 104 ms 36640 KiB
random2_00.txt AC 122 ms 37096 KiB
random2_01.txt AC 174 ms 42332 KiB
random2_02.txt AC 133 ms 38280 KiB
random2_03.txt AC 139 ms 38212 KiB
random2_04.txt AC 141 ms 38872 KiB
random2_05.txt AC 131 ms 38536 KiB
random2_06.txt AC 138 ms 39664 KiB
random2_07.txt AC 158 ms 40860 KiB
random2_08.txt AC 141 ms 38320 KiB
random2_09.txt AC 137 ms 37664 KiB
random_00.txt AC 152 ms 40064 KiB
random_01.txt AC 154 ms 40976 KiB
random_02.txt AC 162 ms 40808 KiB
random_03.txt AC 146 ms 38396 KiB
random_04.txt AC 136 ms 39688 KiB
random_05.txt AC 142 ms 40520 KiB
random_06.txt AC 161 ms 41064 KiB
random_07.txt AC 138 ms 39612 KiB
random_08.txt AC 145 ms 40168 KiB
random_09.txt AC 152 ms 39660 KiB