結果

問題 No.1654 Binary Compression
ユーザー 👑 ygussanyygussany
提出日時 2021-06-17 20:58:42
言語 C
(gcc 12.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,188 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 31,616 KB
実行使用メモリ 35,072 KB
最終ジャッジ日時 2024-04-22 03:22:11
合計ジャッジ時間 5,923 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 13 ms
5,376 KB
testcase_43 WA -
testcase_44 AC 12 ms
5,376 KB
testcase_45 AC 13 ms
5,376 KB
testcase_46 AC 12 ms
5,376 KB
testcase_47 AC 1 ms
5,376 KB
testcase_48 AC 1 ms
5,376 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const int Mod = 998244353;

typedef struct List {
	struct List *next;
	int len;
	long long sum;
} list;

int main()
{
	char S[2000001];
	scanf("%s", S);
	
	int i, j, k = 0, n = 0, A[2000001];
	for (i = 0; S[i] != 0; i = j) {
		for (j = i + 1; S[j] == S[i]; j++);
		if (S[i] == '0') {
			if (n < j - i) n = j - i;
			A[k++] = i - j;
		} else A[k++] = j - i;
	}
	
	int m = 0;
	long long ans = 1, zero_lr = 1, tmp;
	list head, tail, d[2000001], *p;
	head.len = 0;
	tail.len = n + 1;
	tail.sum = 0;
	head.next = &tail;
	tail.next = NULL;
	if (A[k-1] < 0) zero_lr = -A[--k] + 1;
	if (k > 0) {
		i = 0;
		if (A[0] < 0) {
			zero_lr = zero_lr * (-A[0] + 1) % Mod;
			ans = A[++i];
		} else ans = A[i];
		for (i += 2, j = i - 1; i < k; i += 2, j += 2) {
			for (p = &head; p->next->len <= -A[j]; p = p->next);
			d[m].len = -A[j];
			d[m].sum = ans;
			d[m].next = p->next;
			head.next = &(d[m++]);
			for (p = &head, tmp = 0; p->next->len <= n; p = p->next) tmp += p->next->sum * (p->next->len - p->len) % Mod;
			ans += (tmp % Mod + 1) * A[i] % Mod;
			if (ans >= Mod) ans -= Mod;
		}
	} else zero_lr--;
	printf("%lld\n", ans * zero_lr % Mod);
	fflush(stdout);
	return 0;
}
0