結果

問題 No.2879 Range Flip Queries
ユーザー Tatsu_mr
提出日時 2024-09-29 11:56:12
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 415 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 245,336 KB
実行使用メモリ 7,296 KB
最終ジャッジ日時 2024-09-29 11:56:33
合計ジャッジ時間 13,764 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> imos(n + 1);
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--;
        imos[l]++;
        imos[r]--;
    }
    for (int i = 1; i <= n; i++) {
        imos[i] += imos[i - 1];
    }
    for (int i = 0; i < n; i++) {
        cout << (imos[i] % 2 == 0 ? a[i] : 1 - a[i]) << " ";
    }
    cout << endl;
}
0