結果
| 問題 |
No.1441 MErGe
|
| コンテスト | |
| ユーザー |
りあん
|
| 提出日時 | 2021-03-26 22:55:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 429 ms / 1,000 ms |
| コード長 | 1,264 bytes |
| コンパイル時間 | 2,046 ms |
| コンパイル使用メモリ | 204,004 KB |
| 最終ジャッジ日時 | 2025-01-19 23:20:55 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 28 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/lazysegtree>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;
// const int M = 998244353;
const long long LM = 1LL << 60;
int op(int a, int b) {
return a + b;
}
int e() {
return 0;
}
int mapping(bool a, int b) {
return a ? 0 : b;
}
bool composition(bool a, bool b) {
return a || b;
}
bool id() {
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int n, q;
cin >> n >> q;
vector<long long> imos(n + 1);
for (int i = 0; i < n; ++i) {
int a;
cin >> a;
imos[i + 1] = imos[i] + a;
}
atcoder::lazy_segtree<int, op, e, bool, mapping, composition, id> sg(vector<int>(n, 1));
for (int _ = 0; _ < q; ++_) {
int t, l, r;
cin >> t >> l >> r;
--l;
if (t == 1) {
int ll = sg.max_right(0, [&](int x){ return x <= l; });
int rr = sg.max_right(0, [&](int x){ return x <= r; });
sg.apply(ll + 1, rr, true);
}
else {
int ll = sg.max_right(0, [&](int x){ return x <= l; });
int rr = sg.max_right(0, [&](int x){ return x <= r; });
cout << imos[rr] - imos[ll] << '\n';
}
}
return 0;
}
りあん