結果

問題 No.1439 Let's Compare!!!!
ユーザー first_vil
提出日時 2021-03-10 14:52:42
言語 Kotlin
(2.1.0)
結果
AC  
実行時間 1,241 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 14,826 ms
コンパイル使用メモリ 441,036 KB
実行使用メモリ 104,260 KB
最終ジャッジ日時 2024-11-29 08:33:45
合計ジャッジ時間 29,221 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve() {
    val n = nextInt()
    var s = next().toCharArray()
    var t = next().toCharArray()

    var pq = PriorityQueue<Int>()
    for (i in 0 until n) if (s[i] != t[i]) pq.add(i)

    val q = nextInt()
    val ans = Array<String>(q) { "" }
    for(i in 0 until q) {
        val c = next()
        val x = nextInt() - 1
        if (c == "S") s[x] = ('0' + nextInt()).toChar()
        else t[x] = ('0' + nextInt()).toChar()
        if (s[x] != t[x]) pq.add(x)

        while (pq.isNotEmpty() && s[pq.peek()] == t[pq.peek()]) pq.remove()

        if (pq.isEmpty()) ans[i] = "="
        else {
            val k = pq.peek()
            if (s[k] < t[k]) ans[i] = "<"
            else ans[i] = ">"
        }
    }
    println(ans.joinToString("\n"))
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve()
    writer.flush()
}

// region Scanner
private var st = StringTokenizer("")
private val br = System.`in`.bufferedReader()

fun next(): String {
    while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
    return st.nextToken()
}

fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextLine() = br.readLine()!!
fun nextDouble() = next().toDouble()
// endregion
0