結果

問題 No.2879 Range Flip Queries
ユーザー t98slidert98slider
提出日時 2024-09-08 12:32:00
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 783 bytes
コンパイル時間 2,242 ms
コンパイル使用メモリ 202,072 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-09-08 12:32:09
合計ジャッジ時間 8,977 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}

template<class T> ostream& operator << (ostream& os, const vector<T>& vec) {
    if(vec.empty()) return os;
    os << vec[0];
    for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it;
    return os;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> a(n), imos(n + 1);
    cin >> a;
    while(q--){
        int l, r;
        cin >> l >> r;
        l--;
        imos[l] ^= 1;
        imos[r] ^= 1;
    }
    for(int i = 0; i < n; i++){
        imos[i + 1] ^= imos[i];
        a[i] ^= imos[i];
    }
    cout << a << '\n';
}
0