結果
問題 |
No.879 Range Mod 2 Query
|
ユーザー |
👑 |
提出日時 | 2019-09-06 22:45:22 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,527 ms / 3,000 ms |
コード長 | 1,578 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 109,052 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 22:15:07 |
合計ジャッジ時間 | 13,796 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 |
ソースコード
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC target ("avx") #include <cassert> #include <cmath> #include <cstdint> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; using Int = long long; template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; }; template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; } template <class T> void chmin(T &t, const T &f) { if (t > f) t = f; } template <class T> void chmax(T &t, const T &f) { if (t < f) t = f; } int N, Q; Int a[100010]; int main() { for (; ~scanf("%d%d", &N, &Q); ) { for (int i = 0; i < N; ++i) { scanf("%lld", &a[i]); } for (int q = 0; q < Q; ++q) { int typ, l, r; scanf("%d%d%d", &typ, &l, &r); --l; if (typ == 1) { for (int i = l; i < r; ++i) { a[i] %= 2; } } else if (typ == 2) { Int x; scanf("%lld", &x); for (int i = l; i < r; ++i) { a[i] += x; } } else { Int ans = 0; for (int i = l; i < r; ++i) { ans += a[i]; } printf("%lld\n", ans); } } } return 0; }