結果
| 問題 |
No.2879 Range Flip Queries
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-09-08 12:32:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 212 ms / 2,000 ms |
| コード長 | 783 bytes |
| コンパイル時間 | 2,145 ms |
| コンパイル使用メモリ | 194,376 KB |
| 最終ジャッジ日時 | 2025-02-24 05:19:46 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#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';
}