結果

問題 No.1000 Point Add and Array Add
ユーザー kotamanegikotamanegi
提出日時 2020-02-28 21:33:07
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 2,182 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 136,756 KB
実行使用メモリ 27,368 KB
最終ジャッジ日時 2023-08-20 14:04:17
合計ジャッジ時間 7,241 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
9,612 KB
testcase_01 AC 3 ms
11,652 KB
testcase_02 AC 2 ms
7,572 KB
testcase_03 AC 3 ms
7,576 KB
testcase_04 AC 2 ms
9,604 KB
testcase_05 AC 3 ms
9,640 KB
testcase_06 AC 3 ms
9,620 KB
testcase_07 AC 2 ms
9,680 KB
testcase_08 AC 3 ms
11,672 KB
testcase_09 AC 3 ms
9,644 KB
testcase_10 AC 2 ms
9,668 KB
testcase_11 AC 3 ms
9,604 KB
testcase_12 AC 3 ms
7,772 KB
testcase_13 AC 3 ms
7,744 KB
testcase_14 AC 5 ms
9,876 KB
testcase_15 AC 3 ms
7,840 KB
testcase_16 AC 167 ms
23,772 KB
testcase_17 AC 146 ms
19,708 KB
testcase_18 AC 240 ms
26,244 KB
testcase_19 AC 245 ms
26,708 KB
testcase_20 AC 174 ms
16,732 KB
testcase_21 AC 238 ms
27,368 KB
testcase_22 AC 219 ms
24,532 KB
testcase_23 AC 237 ms
26,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:2:18: warning: '#pragma comment linker' ignored [-Wignored-pragmas]
#pragma comment (linker, "/STACK:526000000")
                 ^
1 warning generated.

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
ll seg_tree[seg_size * 4];
ll lazy_seg[seg_size * 4];
ll seg_find(int now, int n_l, int n_r, int w_l, int w_r, int settings) {
	if (w_l <= n_l && n_r <= w_r) {
		lazy_seg[now] += settings;
	}
	if (lazy_seg[now] != 0) {
		seg_tree[now] += lazy_seg[now];
		lazy_seg[now * 2] += lazy_seg[now];
		lazy_seg[now * 2 + 1] += lazy_seg[now];
		lazy_seg[now] = 0;
	}
	if (w_l <= n_l && n_r <= w_r) {
		return seg_tree[now];
	}
	if (w_r <= n_l || n_r <= w_l) {
		return 0;
	}
	return seg_find(now * 2, n_l, (n_l + n_r) / 2, w_l, w_r, settings) + seg_find(now * 2 + 1, (n_l + n_r) / 2, n_r, w_l, w_r, settings);
}
ll ans[300000];
void solve() {
	int n, query;
	cin >> n >> query;
	vector<tuple<int, int, int>> queries;
	REP(i, n) {
		int a;
		cin >> a;
		queries.push_back(make_tuple(0, a, i));
	}
	REP(i, query) {
		int b, c;
		string a;
		cin >> a >> b >> c;
		b--; c--;
		if (a == "A") {
			queries.push_back(make_tuple(0, c + 1LL, b));
		}
		else {
			queries.push_back(make_tuple(1, b, c));
		}
	}
	reverse(ALL(queries));
	REP(i, queries.size()) {
		if (get<0>(queries[i]) == 1) {
			seg_find(1, 0, seg_size, get<1>(queries[i]), get<2>(queries[i]) + 1, 1);
		}
		else {
			ans[get<2>(queries[i])] += get<1>(queries[i]) * seg_find(1, 0, seg_size, get<2>(queries[i]), get<2>(queries[i]) + 1, 0);
		}
	}
	REP(i, n) {
		if (i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}

#undef int
int main() {
	init();
	solve();
}
0