結果
| 問題 | No.879 Range Mod 2 Query |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-13 03:14:29 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,031 bytes |
| 記録 | |
| コンパイル時間 | 5,395 ms |
| コンパイル使用メモリ | 391,540 KB |
| 実行使用メモリ | 15,992 KB |
| 最終ジャッジ日時 | 2026-08-13 03:15:04 |
| 合計ジャッジ時間 | 8,452 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 18 |
ソースコード
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pass (void)0
#define INF (1<<30)-1
#define INFLL (1LL<<60)-1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define YesNo(cond) cout << ((cond) ? "Yes\n" : "No\n")
#define YESNO(cond) cout << ((cond) ? "YES\n" : "NO\n")
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
template <typename T> void print(const T& value) { cout << value << "\n"; }
template <typename T> void print(const vector<T>& vec) { for (auto& v : vec) cout << v << " "; cout << "\n"; }
template <typename T> void input(vector<T>& vec) { for (auto& v : vec) cin >> v; };
template <typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using vm = vector<mint>;
struct S {
ll SUM;
ll oddc;
ll evenc;
};
S op(S left, S right) {
return {left.SUM+right.SUM, left.oddc+right.oddc, left.evenc+right.evenc};
}
S e() { return {0, 0, 0}; }
struct F {
ll op1;
ll revoe;
ll val;
};
S mapping(F top, S bottom) {
if (top.op1 == 0) {
bottom.SUM = bottom.oddc;
if (top.revoe == 1) {
swap(bottom.oddc, bottom.evenc);
bottom.SUM = bottom.oddc;
}
}
bottom.SUM += top.val*(bottom.oddc+bottom.evenc);
if (top.val%2 == 1) {
swap(bottom.oddc, bottom.evenc);
}
return bottom;
}
F composition(F top, F bottom) {
bottom.revoe ^= top.revoe;
if (top.op1 == 0) {
bottom.val = top.val;
} else {
bottom.val += top.val;
}
bottom.op1 &= top.op1;
return bottom;
}
F ID() {
return {1, 0, 0};
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(10);
ll N, Q;
cin >> N >> Q;
vl A(N);
input(A);
vector<S> def;
rep (i, N) {
if (A[i]%2 == 0) {
def.push_back({A[i], 0, 1});
} else {
def.push_back({A[i], 1, 0});
}
}
lazy_segtree<S, op, e, F, mapping, composition, ID> seg(def);
while (Q--) {
ll t; cin >> t;
ll l, r;
cin >> l >> r;
l --; r --;
if (t == 1) {
seg.apply(l, r+1, {0, 0, 0});
} else if (t == 2) {
ll x; cin >> x;
seg.apply(l, r+1, {1, x%2, x});
} else {
auto res = seg.prod(l, r+1);
print(res.SUM);
}
}
}
detteiuu