結果

問題 No.2879 Range Flip Queries
コンテスト
ユーザー vjudge1
提出日時 2025-12-04 02:29:50
言語 C++23
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 211 ms / 2,000 ms
コード長 2,297 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,511 ms
コンパイル使用メモリ 279,164 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-12-04 02:30:05
合計ジャッジ時間 15,131 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/*
*    Author: asharusmani
*    Created: Wednesday, 03.12.2025 10:26 PM (GMT+5:30)
*
*    ? If the world was ending, I'd wanna be next to you ?
*    ? If the party was over and our time on Earth was through ?
*    ? I'd wanna hold you just for a while... and die with a smile ?
*/



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

#ifndef ONLINE_JUDGE
#define DEBUG 1
#endif

#if DEBUG
#define del cerr << '\n'
#define debug(...) _debug(#__VA_ARGS__, __VA_ARGS__)
template <class X, class Y>
ostream& operator<<(ostream& os, pair<X, Y> const& p) {
	return os << "(" << p.first << ", " << p.second << ")";
}
template <class Ch, class Tr, class Container>
basic_ostream<Ch, Tr>& operator<<(basic_ostream<Ch, Tr>& os, Container const& x) {
	int i = 0, n = distance(x.begin(), x.end());
	os << "{ ";
	for (const auto& y : x) os << y << (++i < n ? ", " : "");
	return os << " }";
}
template <typename... Args>
void _debug(const char* names, Args&&... args) {
	string_view s(names);
	cerr << "{ ";
	size_t i = 0, cnt = 0, n = sizeof...(args);
	auto next = [&]() {
		while (i < s.size() && (s[i] == ' ' || s[i] == ',')) ++i;
		size_t st = i;
		while (i < s.size() && s[i] != ',') ++i;
		return s.substr(st, i - st);
	};
	((cerr << next() << ": " << args << (++cnt < n ? ", " : "")), ...);
	cerr << " }" << '\n';
}
#else
#define del
#define debug(...)
#endif


#define ll long long
#define nl endl
#define double long double
#define pb push_back
#define forn(i,a,n) for(int i=a;i<n;++i)
#define all(a) a.begin(),a.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define MOD(a,b) ((a%b)+b)%b
#define vi vector<int>
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
#define fastnuces ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t = 1;
#define yesno(b) cout << ((b)? "YES\n" : "NO\n")

void solve() {
	int n, q;
	cin >> n >> q;

	vi a(n + 1);
	forn(i, 1, n + 1)cin >> a[i];
	vi diff(n + 2);

	while (q--) {
		int l, r;
		cin >> l >> r;

		diff[l] += 1;
		diff[r + 1] -= 1;
	}

	forn(i, 1, n + 1)diff[i] += diff[i - 1];

	debug(diff);

	forn(i, 1, n + 1) {

		if (diff[i] & 1) {
			cout << 1 - a[i] << " ";
		}
		else cout << a[i] << " ";
	}
	cout << nl;


}
int32_t main() {
	fastnuces;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}
0