complete 33983.kt
This commit is contained in:
42
storage/zeta/kt/completed/33983.kt
Normal file
42
storage/zeta/kt/completed/33983.kt
Normal file
@@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user