結果

問題 No.2879 Range Flip Queries
ユーザー GOTKAKO
提出日時 2024-09-08 12:33:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 2,228 ms
コンパイル使用メモリ 196,416 KB
最終ジャッジ日時 2025-02-24 05:20:49
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,Q; cin >> N >> Q;
    vector<int> A(N);
    for(auto &a : A) cin >> a;
    vector<int> B(N);
    while(Q--){
        int l,r; cin >> l >> r;
        l--;
        B.at(l) ^= 1;
        if(r != N) B.at(r) ^= 1;
    }
    for(int i=1; i<N; i++) B.at(i) ^= B.at(i-1);
    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << (A.at(i)^B.at(i));
    }
    cout << endl;
}
0