From bff1a8295b00c657728ba224e3354d86ec616812 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Sat, 19 Jul 2025 21:38:08 +0900 Subject: [PATCH] complete 33983.kt --- storage/zeta/kt/completed/33983.kt | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 storage/zeta/kt/completed/33983.kt diff --git a/storage/zeta/kt/completed/33983.kt b/storage/zeta/kt/completed/33983.kt new file mode 100644 index 0000000..ae5bbf6 --- /dev/null +++ b/storage/zeta/kt/completed/33983.kt @@ -0,0 +1,42 @@ +fun isPureWaterString(s: String): Boolean { + if (s.length % 3 != 0) { + return false + } + var leftCntH = 0 + var rightCntH = 0 + var leftCntO = 0 + var rightCntO = 0 + + for ((left, right) in s zip s.reversed()) { + when (left) { + 'H' -> leftCntH++ + 'O' -> leftCntO++ + } + + when (right) { + 'H' -> rightCntH++ + 'O' -> rightCntO++ + } + + if (leftCntO > leftCntH) { + return false + } + + if (rightCntO > rightCntH) { + return false + } + } + + return leftCntH == leftCntO * 2 +} + + +fun main() = with(System.`in`.bufferedReader()) { + this.readLine() + val s = this.readLine() + if (isPureWaterString(s)) { + println("pure") + } else { + println("mix") + } +} \ No newline at end of file