結果

問題 No.1439 Let's Compare!!!!
ユーザー phsplsphspls
提出日時 2022-11-06 18:49:07
言語 Rust
(1.77.0)
結果
AC  
実行時間 326 ms / 2,000 ms
コード長 1,646 bytes
コンパイル時間 2,181 ms
コンパイル使用メモリ 153,796 KB
実行使用メモリ 13,708 KB
最終ジャッジ日時 2023-09-27 12:53:04
合計ジャッジ時間 7,438 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 320 ms
13,612 KB
testcase_11 AC 293 ms
11,104 KB
testcase_12 AC 289 ms
10,932 KB
testcase_13 AC 325 ms
13,708 KB
testcase_14 AC 326 ms
13,704 KB
testcase_15 AC 294 ms
10,276 KB
testcase_16 AC 273 ms
10,272 KB
testcase_17 AC 277 ms
10,012 KB
testcase_18 AC 271 ms
10,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::BTreeSet;

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let mut s = s.trim().chars().map(|c| c as usize - '0' as usize).collect::<Vec<_>>();
    let mut t = String::new();
    std::io::stdin().read_line(&mut t).ok();
    let mut t = t.trim().chars().map(|c| c as usize - '0' as usize).collect::<Vec<_>>();
    let mut q = String::new();
    std::io::stdin().read_line(&mut q).ok();
    let q: usize = q.trim().parse().unwrap();
    let queries = (0..q).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<&str> = temp.trim().split_whitespace().collect();
            (temp[0].chars().nth(0).unwrap(), temp[1].parse::<usize>().unwrap()-1, temp[2].parse::<usize>().unwrap())
        })
        .collect::<Vec<_>>();

    let mut diff_at = BTreeSet::new();
    for i in 0..n {
        if s[i] != t[i] {
            diff_at.insert(i);
        }
    }
    for &(c, x, y) in queries.iter() {
        if c == 'S' {
            s[x] = y;
        } else {
            t[x] = y;
        }
        if s[x] == t[x] {
            diff_at.remove(&x);
        } else {
            diff_at.insert(x);
        }
        if diff_at.is_empty() {
            println!("=");
        } else {
            let idx = *diff_at.iter().nth(0).unwrap();
            if s[idx] > t[idx] {
                println!(">");
            } else {
                println!("<");
            }
        }
    }
}
0