結果

問題 No.2879 Range Flip Queries
ユーザー well-definedwell-defined
提出日時 2024-09-14 09:10:19
言語 Rust
(1.77.0)
結果
AC  
実行時間 151 ms / 2,000 ms
コード長 688 bytes
コンパイル時間 15,232 ms
コンパイル使用メモリ 378,960 KB
実行使用メモリ 45,696 KB
最終ジャッジ日時 2024-09-14 09:10:44
合計ジャッジ時間 24,458 ms
ジャッジサーバーID
(参考情報)
judge3 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 25 ms
5,376 KB
testcase_04 AC 25 ms
5,376 KB
testcase_05 AC 25 ms
5,376 KB
testcase_06 AC 26 ms
5,376 KB
testcase_07 AC 27 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 94 ms
29,044 KB
testcase_14 AC 92 ms
30,848 KB
testcase_15 AC 60 ms
17,308 KB
testcase_16 AC 37 ms
16,488 KB
testcase_17 AC 92 ms
37,952 KB
testcase_18 AC 127 ms
44,912 KB
testcase_19 AC 134 ms
45,056 KB
testcase_20 AC 135 ms
44,924 KB
testcase_21 AC 129 ms
45,520 KB
testcase_22 AC 131 ms
45,040 KB
testcase_23 AC 135 ms
44,928 KB
testcase_24 AC 132 ms
45,696 KB
testcase_25 AC 132 ms
45,664 KB
testcase_26 AC 130 ms
45,696 KB
testcase_27 AC 131 ms
45,656 KB
testcase_28 AC 151 ms
45,696 KB
testcase_29 AC 100 ms
39,424 KB
testcase_30 AC 101 ms
39,424 KB
testcase_31 AC 102 ms
39,424 KB
testcase_32 AC 100 ms
39,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        mut a: [usize; n],
    }
    let mut flag = vec![0; n];
    for _ in 0..q {
        input! {
            l: usize,
            r: usize,
        }
        let l = l-1;
        let r = r-1; 
        flag[l] = if flag[l] == 0 { 1 } else { 0 };
        if r+1 < flag.len() {
            flag[r+1] = if flag[r+1] == 0 { 1 } else { 0 };
        }
    }
    let mut flip = 0;
    for i in 0..n {
        flip ^= flag[i];
        a[i] = if flip == 1 { a[i] ^ flip } else { a[i] };
    }
    println!("{}", a.iter()
        .map(|&x| x.to_string())
        .collect::<Vec<String>>()
        .join(" "));
}
0