結果

問題 No.2170 Left Addition Machine
ユーザー norikamenorikame
提出日時 2022-12-25 13:56:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 744 ms / 2,000 ms
コード長 1,418 bytes
コンパイル時間 5,591 ms
コンパイル使用メモリ 320,112 KB
実行使用メモリ 28,416 KB
最終ジャッジ日時 2024-04-29 19:38:36
合計ジャッジ時間 55,210 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,248 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 652 ms
27,904 KB
testcase_04 AC 235 ms
5,376 KB
testcase_05 AC 375 ms
15,104 KB
testcase_06 AC 395 ms
16,896 KB
testcase_07 AC 561 ms
25,216 KB
testcase_08 AC 95 ms
14,976 KB
testcase_09 AC 441 ms
9,216 KB
testcase_10 AC 64 ms
5,376 KB
testcase_11 AC 290 ms
15,872 KB
testcase_12 AC 662 ms
28,288 KB
testcase_13 AC 677 ms
28,160 KB
testcase_14 AC 679 ms
28,288 KB
testcase_15 AC 695 ms
28,160 KB
testcase_16 AC 673 ms
28,288 KB
testcase_17 AC 691 ms
28,288 KB
testcase_18 AC 676 ms
28,160 KB
testcase_19 AC 687 ms
28,160 KB
testcase_20 AC 699 ms
28,160 KB
testcase_21 AC 395 ms
5,376 KB
testcase_22 AC 387 ms
5,376 KB
testcase_23 AC 393 ms
5,376 KB
testcase_24 AC 388 ms
5,376 KB
testcase_25 AC 387 ms
5,376 KB
testcase_26 AC 403 ms
5,376 KB
testcase_27 AC 391 ms
5,376 KB
testcase_28 AC 391 ms
5,376 KB
testcase_29 AC 386 ms
5,376 KB
testcase_30 AC 734 ms
28,160 KB
testcase_31 AC 734 ms
28,288 KB
testcase_32 AC 733 ms
28,160 KB
testcase_33 AC 727 ms
28,160 KB
testcase_34 AC 739 ms
28,160 KB
testcase_35 AC 744 ms
28,160 KB
testcase_36 AC 728 ms
28,160 KB
testcase_37 AC 724 ms
28,160 KB
testcase_38 AC 723 ms
28,288 KB
testcase_39 AC 394 ms
5,376 KB
testcase_40 AC 404 ms
5,376 KB
testcase_41 AC 391 ms
5,376 KB
testcase_42 AC 384 ms
5,376 KB
testcase_43 AC 393 ms
5,376 KB
testcase_44 AC 384 ms
5,376 KB
testcase_45 AC 386 ms
5,376 KB
testcase_46 AC 382 ms
5,376 KB
testcase_47 AC 389 ms
5,376 KB
testcase_48 AC 723 ms
28,288 KB
testcase_49 AC 719 ms
28,160 KB
testcase_50 AC 735 ms
28,160 KB
testcase_51 AC 733 ms
28,288 KB
testcase_52 AC 741 ms
28,416 KB
testcase_53 AC 714 ms
28,160 KB
testcase_54 AC 714 ms
28,288 KB
testcase_55 AC 715 ms
28,288 KB
testcase_56 AC 723 ms
28,160 KB
testcase_57 AC 666 ms
28,160 KB
testcase_58 AC 666 ms
28,160 KB
testcase_59 AC 705 ms
28,288 KB
testcase_60 AC 694 ms
28,160 KB
testcase_61 AC 671 ms
28,160 KB
testcase_62 AC 675 ms
28,160 KB
testcase_63 AC 684 ms
28,160 KB
testcase_64 AC 662 ms
28,288 KB
testcase_65 AC 668 ms
28,160 KB
testcase_66 AC 130 ms
5,376 KB
testcase_67 AC 604 ms
28,288 KB
testcase_68 AC 662 ms
28,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

using ll = long long;

#define rep(i, n) for (int i=0; i<(int)(n); ++(i))
#define rep3(i, m, n) for (int i=(m); (i)<(int)(n); ++(i))
#define repr(i, n) for (int i=(int)(n)-1; (i)>=0; --(i))
#define rep3r(i, m, n) for (int i=(int)(n)-1; (i)>=(int)(m); --(i))
#define all(x) (x).begin(), (x).end()

const ll mod = 998244353LL;
const int INF = (int)(1e9);
vector<ll> two;
tuple<int, int, int, ll, int> op(tuple<int, int, int, ll, int> a, tuple<int, int, int, ll, int> b) {
	if (get<4>(b) == -1) return a;
	if (get<4>(a) == -1) return b;
	if (get<4>(b)<get<2>(b) || get<1>(a)>=get<0>(b)) return make_tuple(get<0>(a), get<1>(b), get<2>(a)+get<2>(b), get<3>(b), get<4>(b));
	return make_tuple(get<0>(a), get<1>(b), get<2>(a)+get<2>(b), (get<3>(a)+((get<3>(b)-get<0>(b)+mod)*2+get<0>(b))%mod*two[get<4>(a)-1]%mod)%mod, get<4>(a)+get<4>(b));
}

tuple<int, int, int, ll, int> e() { return make_tuple(-INF, -INF, 0, -INF, -1); }

int main() {
	int n, q;
	cin >> n >> q;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	two.assign(n+1, 0);
	two[0] = 1;
	rep(i, n) two[i+1] = two[i] * 2 % mod;
	segtree<tuple<int, int, int, ll, int>, op, e> st(n);
	rep(i, n) st.set(i, make_tuple(a[i], a[i], 1, a[i], 1));
	rep(i, q) {
		int li, ri;
		cin >> li >> ri;
		--li;
		ll res = get<3>(st.prod(li, ri));
		cout << res << endl;
	}
	return 0;
}
0