結果

問題 No.1439 Let's Compare!!!!
ユーザー first_vilfirst_vil
提出日時 2021-03-10 14:52:42
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,139 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 15,148 ms
コンパイル使用メモリ 419,596 KB
実行使用メモリ 76,224 KB
最終ジャッジ日時 2023-08-19 15:07:55
合計ジャッジ時間 27,414 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 276 ms
56,184 KB
testcase_01 AC 276 ms
56,264 KB
testcase_02 AC 276 ms
56,008 KB
testcase_03 AC 278 ms
56,336 KB
testcase_04 AC 280 ms
56,332 KB
testcase_05 AC 279 ms
56,044 KB
testcase_06 AC 278 ms
56,308 KB
testcase_07 AC 418 ms
59,420 KB
testcase_08 AC 429 ms
59,384 KB
testcase_09 AC 377 ms
59,384 KB
testcase_10 AC 930 ms
69,400 KB
testcase_11 AC 1,081 ms
75,556 KB
testcase_12 AC 1,075 ms
76,224 KB
testcase_13 AC 889 ms
70,440 KB
testcase_14 AC 856 ms
70,084 KB
testcase_15 AC 1,074 ms
75,632 KB
testcase_16 AC 1,092 ms
75,784 KB
testcase_17 AC 1,139 ms
73,740 KB
testcase_18 AC 990 ms
73,176 KB
権限があれば一括ダウンロードができます

ソースコード

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