結果

問題 No.945 YKC饅頭
ユーザー bal4ubal4u
提出日時 2019-12-08 10:04:05
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 1,868 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 30,036 KB
実行使用メモリ 11,784 KB
最終ジャッジ日時 2023-08-28 15:18:43
合計ジャッジ時間 7,594 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 8 ms
8,296 KB
testcase_32 AC 4 ms
8,276 KB
testcase_33 AC 38 ms
10,284 KB
testcase_34 AC 94 ms
9,232 KB
testcase_35 AC 172 ms
11,420 KB
testcase_36 AC 98 ms
5,564 KB
testcase_37 AC 96 ms
9,456 KB
testcase_38 AC 93 ms
9,304 KB
testcase_39 AC 22 ms
8,408 KB
testcase_40 AC 20 ms
10,096 KB
testcase_41 AC 7 ms
8,320 KB
testcase_42 AC 146 ms
9,652 KB
testcase_43 AC 82 ms
5,184 KB
testcase_44 AC 130 ms
11,152 KB
testcase_45 AC 149 ms
9,808 KB
testcase_46 AC 3 ms
8,268 KB
testcase_47 AC 94 ms
9,072 KB
testcase_48 AC 17 ms
4,380 KB
testcase_49 AC 40 ms
8,628 KB
testcase_50 AC 163 ms
9,872 KB
testcase_51 AC 208 ms
11,732 KB
testcase_52 AC 216 ms
11,696 KB
testcase_53 AC 208 ms
11,728 KB
testcase_54 AC 209 ms
11,784 KB
testcase_55 AC 212 ms
11,780 KB
testcase_56 AC 2 ms
8,148 KB
testcase_57 AC 3 ms
8,276 KB
testcase_58 AC 80 ms
11,092 KB
testcase_59 AC 100 ms
11,476 KB
testcase_60 AC 38 ms
10,468 KB
testcase_61 AC 89 ms
11,176 KB
testcase_62 AC 84 ms
11,108 KB
testcase_63 AC 4 ms
9,768 KB
testcase_64 AC 40 ms
10,476 KB
testcase_65 AC 32 ms
10,412 KB
testcase_66 AC 31 ms
10,316 KB
testcase_67 AC 61 ms
10,768 KB
testcase_68 AC 38 ms
10,436 KB
testcase_69 AC 14 ms
10,148 KB
testcase_70 AC 17 ms
10,188 KB
testcase_71 AC 18 ms
10,172 KB
testcase_72 AC 50 ms
10,716 KB
testcase_73 AC 96 ms
11,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 945 YKC饅頭
// 2019.12.8 bal4u

#include <stdio.h>
#include <string.h>

typedef long long ll;

//// 入力の高速化
int getchar_unlocked();
#define gc() getchar_unlocked()

int in() {    // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

// セグメント木
#define MAXN (1<<18)      // セグメント木のサイズ。2のべき乗にすべし
#define INF  0x7777777777777777LL

ll segVal[2*MAXN];
ll segLazy[2*MAXN];

void lazy(int k, int l, int r) {
	if (segLazy[k] != INF) {
		segVal[k] = (r-l)*segLazy[k];
		if (l + 1 < r) {
			segLazy[(k << 1) + 1] = segLazy[k];
			segLazy[(k << 1) + 2] = segLazy[k];
		}
		segLazy[k] = INF;
	}
}

void update(int a, int b, ll x, int k, int l, int r) {
	lazy(k, l, r);
	if (r <= a || b <= l) return;
	if (a <= l && r <= b) {
		segLazy[k] = x;
		lazy(k, l, r);
		return;
	}
	update(a, b, x, (k << 1) + 1, l, (l + r) >> 1);
	update(a, b, x, (k << 1) + 2, (l + r) >> 1, r);
	segVal[k] = segVal[(k << 1) + 1] + segVal[(k << 1) + 2];
}

ll getSum(int a, int b, int k, int l, int r) {
	ll ans;

	if (r <= a || b <= l) return 0;
	lazy(k, l, r);
	if (a <= l && r <= b) return segVal[k];
	ans = getSum(a, b, (k << 1) + 1, l, (l + r) >> 1);
	ans += getSum(a, b, (k << 1) + 2, (l + r) >> 1, r);
	return ans;
}

#define T6  1000000
#define T12 1000000000000LL

ll x[128];
int L[200005], R[200005]; char T[200005];

int main()
{
	int i, N, M;
    ll s;

    x['Y'] = 1, x['K'] = T6, x['C'] = T12;
	N = in(), M = in();
//	memset(segLazy, 0x77, sizeof(segLazy));
    for (i = 0; i < 2*N; i++) segLazy[i] = INF;
	for (i = 0; i < M; ++i) {
		L[i] = in(), R[i] = in(), T[i] = gc(), gc();
    }
    while (i--) update(L[i]-1, R[i], x[T[i]], 0, 0, N);
    s = getSum(0, N+1, 0, 0, N);
	printf("%d %d %d\n", (int)(s%T6), (int)((s/T6)%T6), (int)(s/T12));
	return 0;
}
0