結果

問題 No.2879 Range Flip Queries
ユーザー GOTKAKOGOTKAKO
提出日時 2024-09-08 12:33:34
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 204,048 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-09-08 12:33:50
合計ジャッジ時間 8,570 ms
ジャッジサーバーID
(参考情報)
judge4 / 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