結果

問題 No.945 YKC饅頭
ユーザー bal4ubal4u
提出日時 2019-12-08 09:42:46
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,884 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 30,172 KB
実行使用メモリ 11,804 KB
最終ジャッジ日時 2023-08-28 14:56:20
合計ジャッジ時間 9,292 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 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,384 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 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,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 8 ms
8,288 KB
testcase_32 AC 4 ms
8,292 KB
testcase_33 AC 39 ms
10,372 KB
testcase_34 AC 94 ms
9,156 KB
testcase_35 AC 169 ms
11,504 KB
testcase_36 AC 96 ms
5,568 KB
testcase_37 AC 92 ms
9,472 KB
testcase_38 AC 90 ms
9,372 KB
testcase_39 AC 23 ms
8,412 KB
testcase_40 AC 18 ms
10,116 KB
testcase_41 AC 7 ms
8,336 KB
testcase_42 AC 139 ms
9,600 KB
testcase_43 AC 78 ms
5,196 KB
testcase_44 AC 126 ms
11,040 KB
testcase_45 AC 143 ms
9,832 KB
testcase_46 AC 3 ms
8,288 KB
testcase_47 AC 92 ms
9,148 KB
testcase_48 AC 17 ms
4,380 KB
testcase_49 AC 38 ms
8,532 KB
testcase_50 AC 166 ms
9,912 KB
testcase_51 AC 206 ms
11,784 KB
testcase_52 AC 205 ms
11,664 KB
testcase_53 AC 208 ms
11,676 KB
testcase_54 AC 214 ms
11,804 KB
testcase_55 AC 217 ms
11,668 KB
testcase_56 AC 2 ms
8,032 KB
testcase_57 AC 2 ms
7,992 KB
testcase_58 AC 84 ms
11,084 KB
testcase_59 AC 99 ms
11,376 KB
testcase_60 AC 37 ms
10,480 KB
testcase_61 AC 89 ms
11,240 KB
testcase_62 AC 84 ms
11,236 KB
testcase_63 AC 5 ms
9,780 KB
testcase_64 AC 42 ms
10,480 KB
testcase_65 AC 34 ms
10,468 KB
testcase_66 AC 31 ms
10,444 KB
testcase_67 AC 62 ms
10,796 KB
testcase_68 AC 39 ms
10,488 KB
testcase_69 AC 15 ms
10,084 KB
testcase_70 AC 18 ms
10,184 KB
testcase_71 AC 17 ms
10,164 KB
testcase_72 AC 54 ms
10,708 KB
testcase_73 AC 95 ms
11,296 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;
}

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

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

    x['Y'] = 1, x['K'] = 1000000, x['C'] = 1000000000000LL;
	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%1000000), (int)((s/1000000)%1000000),
        (int)(s/1000000000000LL));
	return 0;
}
0