QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296087#4893. Imbalancezyc07041970 1871ms55104kbC++148.8kb2024-01-02 08:31:062024-01-02 08:31:06

Judging History

你现在查看的是最新测评结果

  • [2024-01-02 08:31:06]
  • 评测
  • 测评结果:70
  • 用时:1871ms
  • 内存:55104kb
  • [2024-01-02 08:31:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;

inline int add(int x, int y) {x += y; return x >= mod ? x - mod : x;}
inline int del(int x, int y) {x -= y; return x < 0 ? x + mod : x;}
inline void Add(int &x, int y) {x = add(x, y);}
inline void Del(int &x, int y) {x = del(x, y);}

int n, k, m, a[200];
char s[200];

namespace subtask1 {
	int dp[2][(1 << 22) + 3], opt, ans, cnt[(1 << 22) + 3];
	
	void work() {
		memset(dp, 0, sizeof(dp));
		dp[opt][0] = 1;
		for (int i = 1; i <= n; ++i) {
			opt ^= 1;
			for (int S = 0; S < (1 << k); ++S) dp[opt][S] = 0;
			for (int S = 0, T; S < (1 << k); ++S) {
				if (cnt[S] >= (k / 2)) continue;
				if (i > m || a[i] == 0) {
					T = (S >> 1);
					Add(dp[opt][T], dp[opt ^ 1][S]);
				}
				if (i > m || a[i] == 1) {
					T = (S >> 1) | (1 << (k - 1));
					if (cnt[T] >= (k / 2)) continue;
					Add(dp[opt][T], dp[opt ^ 1][S]);
				}
			}
		}
		for (int S = 0; S < (1 << k); ++S) Add(ans, dp[opt][S]);
	}
	
	void solve() {
		for (int i = 1; i < (1 << k); ++i) cnt[i] = cnt[i ^ (i & -i)] + 1;
		work();
		for (int i = 1; i <= m; ++i) a[i] ^= 1;
		work();
		printf("%d\n", ans);
	}
}

namespace subtask2 {
	const int Mod = 10997;
	struct Hash_Table {
		struct edge {
			int to, nxt;
			edge() {}
			edge(int x, int y) {to = x; nxt = y;}
		};
		struct node {
			vector<int> id;
			int val;
			node() {}
			node(vector<int> x, int y) {id = x; val = y;}
		};
		vector<node> q;
		vector<edge> e;
		int link[Mod + 10];
		
		inline int g(int x) {return (1ll * x * x % Mod * x % Mod + (x ^ 287) % Mod) % Mod + 1;}
		inline int f(vector<int> &tmp) {
			int res = 0;
			for (auto x : tmp) res = (res + g(x)) % Mod;
			return res;
		}
		void ins(vector<int> &tmp, int val) {
			if (val == 0) return;
			int ID = f(tmp); bool pd;
			for (int i = link[ID], y; i; i = e[i].nxt) {
				y = e[i].to; pd = true;
				for (int j = 0; j < q[y].id.size(); ++j) pd &= (q[y].id[j] == tmp[j]);
				if (pd) {
					Add(q[y].val, val);
					return;
				}
			}
			q.push_back(node(tmp, val));
			e.push_back(edge(q.size() - 1, link[ID]));
			link[ID] = e.size() - 1;
		}
		
		void clear() {
			e.clear(); e.push_back(edge());
			q.clear();
			for (int i = 1; i <= Mod; ++i) link[i] = 0;
		}
	}H[2];
	int st[10], mx, opt, ans;
	vector<int> now, nxt;
	
	void work() {
		H[0].clear(); H[1].clear();
		now.resize(mx + 1);
		for (int i = 0; i <= mx; ++i) now[i] = 0;
		H[opt].ins(now, 1);
		int pos;
		for (int i = 1; i < k; ++i) {
			for (int j = 0; j <= mx; ++j) {
				pos = j * k + i;
				opt ^= 1;
				for (auto o : H[opt ^ 1].q) {
					now = o.id;
					if (pos > m || a[pos] == 0) {
						nxt = now; bool pd = true;
						if (j < mx && st[j] + nxt[j] + k - i - ((j + 1) * k <= m && a[(j + 1) * k] == 0) < st[j + 1]) pd = false;
						if (j < mx && st[j] + nxt[j] + ((j + 1) * k <= m && a[(j + 1) * k] == 1) > st[j + 1]) pd = false;
						if (j && nxt[j - 1] + st[j - 1] > nxt[j] + st[j]) pd = false;
						if (j && nxt[j - 1] + st[j - 1] + k / 2 <= nxt[j] + st[j]) pd = false;
						if (pd) H[opt].ins(nxt, o.val);
					}
					if (pos <= n && (pos > m || a[pos] == 1)) {
						nxt = now; bool pd = true;
						nxt[j]++;
						if (j < mx && st[j] + nxt[j] + k - i - ((j + 1) * k <= m && a[(j + 1) * k] == 0) < st[j + 1]) pd = false;
						if (j < mx && st[j] + nxt[j] + ((j + 1) * k <= m && a[(j + 1) * k] == 1) > st[j + 1]) pd = false;
						if (j && nxt[j - 1] + st[j - 1] > nxt[j] + st[j]) pd = false;
						if (j && nxt[j - 1] + st[j - 1] + k / 2 <= nxt[j] + st[j]) pd = false;
						if (pd) H[opt].ins(nxt, o.val);
					}
				}
				H[opt ^ 1].clear();
			}
		}
		for (auto o : H[opt].q) {
			now = o.id;
			Add(ans, o.val);
		}
	}
	
	void dfs(int t, int lst) {
		if (t > mx) return work(), void();
		for (int i = lst; i < lst + k / 2; ++i) {
			st[t] = i;
			dfs(t + 1, i);
		}
	}
	
	void solve() {
		mx = n / k;
		dfs(1, 0);
		for (int i = 1; i <= m; ++i) a[i] ^= 1;
		dfs(1, 0);
		printf("%d\n", ans);
	}
}

namespace subtask3 {
	struct node {
		int x, y;
	}p[10];
	int st[10], a[10][10], ans, mx, fac[505], inv[505];
	
	inline int qpow(int x, int y) {
		int res = 1;
		while (y) {
			if (y & 1) res = 1ll * res * x % mod;
			x = 1ll * x * x % mod;
			y >>= 1;
		}
		return res;
	}
	inline int C(int x, int y) {return (x < 0 || y < 0 || x < y) ? 0 : 1ll * fac[x] * inv[y] % mod * inv[x - y] % mod;}
	
	void work() {
		for (int i = 0; i < mx; ++i) {
			p[i].x = st[i] - k / 2 * i;
			p[i].y = st[i + 1] - k / 2 * i;
		}
		p[mx].x = st[mx] - k / 2 * mx;
		p[mx].y = st[mx + 1] - k / 2 * mx;
		for (int i = 0; i <= mx; ++i) {
			for (int j = 0; j <= mx; ++j) {
				if (j < mx) {
					if (p[i].x > p[mx].y) a[i][j] = C(k, p[j].y - p[i].x);
					else {
						a[i][j] = 0;
						for (int o = p[mx].y - p[i].x; o <= p[j].y - p[i].x; ++o) {
							if (o > p[mx].y - p[i].x) Add(a[i][j], 1ll * C(n % k, o) * C(k - n % k, p[j].y - p[i].x - o) % mod);
							else Add(a[i][j], 1ll * C(n % k, o) * C(k - n % k - 1, p[j].y - p[i].x - o - 1) % mod);
						}
					}
				}
				else a[i][j] = C(n % k, p[j].y - p[i].x);
			}
		}
		int res = 1;
		for (int i = 0; i <= mx; ++i) {
			for (int j = i + 1; j <= mx; ++j) {
				while (a[j][i]) {
					swap(a[j], a[i]); res = mod - res;
					int tmp = a[j][i] / a[i][i];
					for (int o = i; o <= mx; ++o) Del(a[j][o], 1ll * tmp * a[i][o] % mod);
				}
			}
			res = 1ll * res * a[i][i] % mod;
		}
		Add(ans, res);
	}
	
	void dfs(int t, int lst) {
		if (t > mx + 1) return work(), void();
		if (t > mx) {
			for (int i = lst; i <= lst + n % k; ++i) {
				st[t] = i;
				dfs(t + 1, i);
			}
			return;
		}
		for (int i = lst; i < lst + k / 2; ++i) {
			st[t] = i;
			dfs(t + 1, i);
		}
	}
	
	void solve() {
		fac[0] = 1;
		for (int i = 1; i <= 500; ++i) fac[i] = 1ll * fac[i - 1] * i % mod;
		inv[500] = qpow(fac[500], mod - 2);
		for (int i = 500; i >= 1; --i) inv[i - 1] = 1ll * inv[i] * i % mod;
		mx = n / k;
		dfs(1, 0); ans = add(ans, ans);
		printf("%d\n", ans);
	}
}

namespace subtask4 {
	const int B = 100;
	
	struct node {
		int x, y;
	}p[10];
	int st[10], A[10][10], ans, mx, dp[1000][1000], vis[200][200];
	
	bool check(int ox, int oy) {return ox < n % k || oy > p[mx].y || (ox == n % k && oy == p[mx].y);}
	
	void work() {
//		for (int i = 0; i <= mx; ++i) printf("%d ", st[i]); puts("");
		int lst_x = 0, lst_y = 0;
		for (int i = 1; i <= m; ++i) {
			if (a[i] == 1) vis[lst_x][lst_y + B] = 1, lst_x++, lst_y++;
			else vis[lst_x][lst_y + B] = -1, lst_x++;
			if (lst_x == k) lst_x = 0, lst_y -= k / 2;
		}
		
		for (int i = 0; i < mx; ++i) {
			p[i].x = st[i] - k / 2 * i;
			p[i].y = st[i + 1] - k / 2 * i;
		}
		p[mx].x = st[mx] - k / 2 * mx;
		p[mx].y = st[mx + 1] - k / 2 * mx;
		
//		for (int i = 0; i <= mx; ++i) printf("(%d %d)->(%d %d)\n", 0, p[i].x, i < mx ? k : n % k, p[i].y);
		
		for (int i = 0; i <= mx; ++i) {
			dp[0][p[i].x + B] = 1;
			for (int ox = 0; ox < k; ++ox)
				for (int oy = p[i].x; oy <= p[0].y; ++oy) {
					if (!dp[ox][oy + B]) continue;
					if (vis[ox][oy + B] != 1 && check(ox, oy + 1)) Add(dp[ox + 1][oy + B], dp[ox][oy + B]);
					if (vis[ox][oy + B] != -1 && check(ox + 1, oy + 1) && oy < p[0].y) Add(dp[ox + 1][oy + B + 1], dp[ox][oy + B]);
				}
			for (int j = 0; j < mx; ++j) A[i][j] = dp[k][p[j].y + B];
			A[i][mx] = dp[n % k][p[mx].y + B];
			for (int ox = 0; ox <= k; ++ox)
				for (int oy = p[i].x; oy <= p[0].y; ++oy)
					dp[ox][oy + B] = 0;
			
//			for (int j = 0; j <= mx; ++j) printf("%d ", A[i][j]);
//			puts("");
		}
//		puts("");
		int res = 1;
		for (int i = 0; i <= mx; ++i) {
			for (int j = i + 1; j <= mx; ++j) {
				while (A[j][i]) {
					swap(A[j], A[i]); res = mod - res;
					int tmp = A[j][i] / A[i][i];
					for (int o = i; o <= mx; ++o) Del(A[j][o], 1ll * tmp * A[i][o] % mod);
				}
			}
			res = 1ll * res * A[i][i] % mod;
		}
		Add(ans, res);
		
		lst_x = 0, lst_y = 0;
		for (int i = 1; i <= m; ++i) {
			vis[lst_x][lst_y] = 0;
			lst_x++; lst_y += a[i];
			if (lst_x == k) lst_x = 0, lst_y -= k / 2;
		}
	}
	
	void dfs(int t, int lst) {
		if (t > mx + 1) return work(), void();
		if (t > mx) {
			for (int i = lst; i <= lst + n % k; ++i) {
				st[t] = i;
				dfs(t + 1, i);
			}
			return;
		}
		for (int i = lst; i < lst + k / 2; ++i) {
			st[t] = i;
			dfs(t + 1, i);
		}
	}
	
	void solve() {
		mx = n / k;
		dfs(1, 0);
		for (int i = 1; i <= m; ++i) a[i] ^= 1;
		dfs(1, 0);
		printf("%d\n", ans);
	}
}

int main() {
	scanf("%d%d%d%s", &n, &k, &m, s + 1);
	for (int i = 1; i <= m; ++i) a[i] = s[i] - '0';
	
//	subtask4 :: solve(); return 0;
	
	if (k <= 20 || (k <= 22 && n <= 66)) subtask1 :: solve();
	else if (n <= 66) subtask2 :: solve();
	else if (m == 0) subtask3 :: solve();
	else subtask4 :: solve();
	return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 38920kb

input:

2 2 0

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 40776kb

input:

2 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 4ms
memory: 39096kb

input:

3 2 0

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 4ms
memory: 38888kb

input:

3 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 9ms
memory: 39956kb

input:

4 2 0

output:

2

result:

ok 1 number(s): "2"

Test #6:

score: 0
Accepted
time: 0ms
memory: 39788kb

input:

4 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #7:

score: 0
Accepted
time: 0ms
memory: 40268kb

input:

4 4 0

output:

10

result:

ok 1 number(s): "10"

Test #8:

score: 0
Accepted
time: 4ms
memory: 39480kb

input:

4 4 1
1

output:

5

result:

ok 1 number(s): "5"

Test #9:

score: 0
Accepted
time: 0ms
memory: 39496kb

input:

4 4 2
00

output:

3

result:

ok 1 number(s): "3"

Test #10:

score: 0
Accepted
time: 3ms
memory: 39524kb

input:

4 4 3
101

output:

1

result:

ok 1 number(s): "1"

Test #11:

score: 0
Accepted
time: 0ms
memory: 39568kb

input:

5 2 0

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 0ms
memory: 39800kb

input:

5 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #13:

score: 0
Accepted
time: 0ms
memory: 39932kb

input:

5 4 0

output:

14

result:

ok 1 number(s): "14"

Test #14:

score: 0
Accepted
time: 3ms
memory: 39292kb

input:

5 4 1
0

output:

7

result:

ok 1 number(s): "7"

Test #15:

score: 0
Accepted
time: 0ms
memory: 38748kb

input:

5 4 2
01

output:

3

result:

ok 1 number(s): "3"

Test #16:

score: 0
Accepted
time: 4ms
memory: 40400kb

input:

5 4 3
110

output:

1

result:

ok 1 number(s): "1"

Test #17:

score: 0
Accepted
time: 0ms
memory: 40304kb

input:

17 2 0

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 0ms
memory: 40336kb

input:

17 2 0

output:

2

result:

ok 1 number(s): "2"

Test #19:

score: 0
Accepted
time: 3ms
memory: 40864kb

input:

17 10 6
110111

output:

621

result:

ok 1 number(s): "621"

Test #20:

score: 0
Accepted
time: 0ms
memory: 40416kb

input:

17 10 2
11

output:

8413

result:

ok 1 number(s): "8413"

Test #21:

score: 0
Accepted
time: 7ms
memory: 40736kb

input:

18 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #22:

score: 0
Accepted
time: 0ms
memory: 40200kb

input:

18 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 3ms
memory: 38964kb

input:

18 8 5
00010

output:

918

result:

ok 1 number(s): "918"

Test #24:

score: 0
Accepted
time: 0ms
memory: 38624kb

input:

18 8 3
001

output:

3404

result:

ok 1 number(s): "3404"

Test #25:

score: 0
Accepted
time: 6ms
memory: 40304kb

input:

18 16 6
100011

output:

2458

result:

ok 1 number(s): "2458"

Test #26:

score: 0
Accepted
time: 4ms
memory: 39176kb

input:

18 16 8
00101101

output:

548

result:

ok 1 number(s): "548"

Test #27:

score: 0
Accepted
time: 0ms
memory: 38924kb

input:

19 2 1
1

output:

1

result:

ok 1 number(s): "1"

Test #28:

score: 0
Accepted
time: 4ms
memory: 39180kb

input:

19 2 0

output:

2

result:

ok 1 number(s): "2"

Test #29:

score: 0
Accepted
time: 0ms
memory: 39144kb

input:

19 6 2
00

output:

3413

result:

ok 1 number(s): "3413"

Test #30:

score: 0
Accepted
time: 0ms
memory: 40220kb

input:

19 6 1
1

output:

7012

result:

ok 1 number(s): "7012"

Test #31:

score: 0
Accepted
time: 0ms
memory: 40572kb

input:

19 12 10
1010110000

output:

266

result:

ok 1 number(s): "266"

Test #32:

score: 0
Accepted
time: 4ms
memory: 40992kb

input:

19 12 3
111

output:

19234

result:

ok 1 number(s): "19234"

Test #33:

score: 0
Accepted
time: 5ms
memory: 40092kb

input:

19 16 2
10

output:

77876

result:

ok 1 number(s): "77876"

Test #34:

score: 0
Accepted
time: 6ms
memory: 40308kb

input:

19 16 0

output:

301208

result:

ok 1 number(s): "301208"

Test #35:

score: 0
Accepted
time: 3ms
memory: 39580kb

input:

20 2 1
0

output:

1

result:

ok 1 number(s): "1"

Test #36:

score: 0
Accepted
time: 3ms
memory: 40304kb

input:

20 2 0

output:

2

result:

ok 1 number(s): "2"

Test #37:

score: 0
Accepted
time: 0ms
memory: 38904kb

input:

20 10 9
110111000

output:

76

result:

ok 1 number(s): "76"

Test #38:

score: 0
Accepted
time: 8ms
memory: 40108kb

input:

20 10 9
110101110

output:

372

result:

ok 1 number(s): "372"

Test #39:

score: 0
Accepted
time: 4ms
memory: 39152kb

input:

20 14 11
10110110000

output:

207

result:

ok 1 number(s): "207"

Test #40:

score: 0
Accepted
time: 0ms
memory: 38984kb

input:

20 14 7
0011011

output:

3675

result:

ok 1 number(s): "3675"

Test #41:

score: 0
Accepted
time: 83ms
memory: 43560kb

input:

20 20 14
10111010000000

output:

58

result:

ok 1 number(s): "58"

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #42:

score: 10
Accepted
time: 8ms
memory: 39064kb

input:

114 12 11
11010000010

output:

394940507

result:

ok 1 number(s): "394940507"

Test #43:

score: 0
Accepted
time: 4ms
memory: 39920kb

input:

114 12 2
01

output:

60509873

result:

ok 1 number(s): "60509873"

Test #44:

score: 0
Accepted
time: 10ms
memory: 38960kb

input:

114 14 10
1001111011

output:

154687039

result:

ok 1 number(s): "154687039"

Test #45:

score: 0
Accepted
time: 3ms
memory: 39516kb

input:

114 14 5
00100

output:

941826071

result:

ok 1 number(s): "941826071"

Test #46:

score: 0
Accepted
time: 18ms
memory: 39308kb

input:

114 16 10
1011101001

output:

391666362

result:

ok 1 number(s): "391666362"

Test #47:

score: 0
Accepted
time: 21ms
memory: 39124kb

input:

114 16 15
000010011111010

output:

599226561

result:

ok 1 number(s): "599226561"

Test #48:

score: 0
Accepted
time: 77ms
memory: 42752kb

input:

114 18 1
0

output:

167675624

result:

ok 1 number(s): "167675624"

Test #49:

score: 0
Accepted
time: 76ms
memory: 41752kb

input:

114 18 8
11000001

output:

165986235

result:

ok 1 number(s): "165986235"

Test #50:

score: 0
Accepted
time: 761ms
memory: 44392kb

input:

114 20 17
11101000010011010

output:

852476378

result:

ok 1 number(s): "852476378"

Test #51:

score: 0
Accepted
time: 778ms
memory: 43272kb

input:

114 20 13
1101011010000

output:

974712368

result:

ok 1 number(s): "974712368"

Test #52:

score: 0
Accepted
time: 0ms
memory: 39796kb

input:

113 12 8
10101100

output:

754580060

result:

ok 1 number(s): "754580060"

Test #53:

score: 0
Accepted
time: 0ms
memory: 39404kb

input:

113 12 10
1110010010

output:

928476173

result:

ok 1 number(s): "928476173"

Test #54:

score: 0
Accepted
time: 4ms
memory: 40544kb

input:

113 14 9
010111000

output:

930953494

result:

ok 1 number(s): "930953494"

Test #55:

score: 0
Accepted
time: 3ms
memory: 40020kb

input:

113 14 0

output:

613264431

result:

ok 1 number(s): "613264431"

Test #56:

score: 0
Accepted
time: 21ms
memory: 40788kb

input:

113 16 4
0011

output:

966491874

result:

ok 1 number(s): "966491874"

Test #57:

score: 0
Accepted
time: 18ms
memory: 39748kb

input:

113 16 10
1110110011

output:

71975445

result:

ok 1 number(s): "71975445"

Test #58:

score: 0
Accepted
time: 73ms
memory: 38972kb

input:

113 18 2
01

output:

35416931

result:

ok 1 number(s): "35416931"

Test #59:

score: 0
Accepted
time: 76ms
memory: 39424kb

input:

113 18 11
01101011111

output:

605684813

result:

ok 1 number(s): "605684813"

Test #60:

score: 0
Accepted
time: 837ms
memory: 44728kb

input:

113 20 1
1

output:

970488755

result:

ok 1 number(s): "970488755"

Test #61:

score: 0
Accepted
time: 749ms
memory: 43700kb

input:

113 20 17
10000001101111001

output:

308768022

result:

ok 1 number(s): "308768022"

Test #62:

score: 0
Accepted
time: 3ms
memory: 40300kb

input:

112 12 10
1011100000

output:

379472486

result:

ok 1 number(s): "379472486"

Test #63:

score: 0
Accepted
time: 0ms
memory: 38920kb

input:

112 12 3
111

output:

876338776

result:

ok 1 number(s): "876338776"

Test #64:

score: 0
Accepted
time: 4ms
memory: 39336kb

input:

112 14 6
100111

output:

850899867

result:

ok 1 number(s): "850899867"

Test #65:

score: 0
Accepted
time: 3ms
memory: 40196kb

input:

112 14 11
11011001011

output:

579315503

result:

ok 1 number(s): "579315503"

Test #66:

score: 0
Accepted
time: 18ms
memory: 38876kb

input:

112 16 11
00000111111

output:

827780781

result:

ok 1 number(s): "827780781"

Test #67:

score: 0
Accepted
time: 19ms
memory: 39820kb

input:

112 16 9
101001101

output:

247916257

result:

ok 1 number(s): "247916257"

Test #68:

score: 0
Accepted
time: 69ms
memory: 42028kb

input:

112 18 16
0011000001111001

output:

740632908

result:

ok 1 number(s): "740632908"

Test #69:

score: 0
Accepted
time: 77ms
memory: 41856kb

input:

112 18 4
0010

output:

594108528

result:

ok 1 number(s): "594108528"

Test #70:

score: 0
Accepted
time: 796ms
memory: 43924kb

input:

112 20 7
1010100

output:

818166882

result:

ok 1 number(s): "818166882"

Test #71:

score: 0
Accepted
time: 746ms
memory: 43204kb

input:

112 20 16
0001100100101000

output:

222914924

result:

ok 1 number(s): "222914924"

Test #72:

score: 0
Accepted
time: 3ms
memory: 39632kb

input:

111 12 2
11

output:

895626591

result:

ok 1 number(s): "895626591"

Test #73:

score: 0
Accepted
time: 0ms
memory: 40000kb

input:

111 12 1
1

output:

543447881

result:

ok 1 number(s): "543447881"

Test #74:

score: 0
Accepted
time: 4ms
memory: 38804kb

input:

111 14 3
111

output:

555958815

result:

ok 1 number(s): "555958815"

Test #75:

score: 0
Accepted
time: 8ms
memory: 39700kb

input:

111 14 13
1110001101010

output:

47749667

result:

ok 1 number(s): "47749667"

Test #76:

score: 0
Accepted
time: 21ms
memory: 39808kb

input:

111 16 5
01000

output:

880732287

result:

ok 1 number(s): "880732287"

Test #77:

score: 0
Accepted
time: 19ms
memory: 42568kb

input:

111 16 7
0110010

output:

153134396

result:

ok 1 number(s): "153134396"

Test #78:

score: 0
Accepted
time: 69ms
memory: 39632kb

input:

111 18 17
11011101001111100

output:

718197735

result:

ok 1 number(s): "718197735"

Test #79:

score: 0
Accepted
time: 75ms
memory: 38876kb

input:

111 18 9
011110101

output:

78875109

result:

ok 1 number(s): "78875109"

Test #80:

score: 0
Accepted
time: 798ms
memory: 43632kb

input:

111 20 6
100101

output:

484008568

result:

ok 1 number(s): "484008568"

Test #81:

score: 0
Accepted
time: 719ms
memory: 43652kb

input:

111 20 19
1100110110001010110

output:

612558978

result:

ok 1 number(s): "612558978"

Test #82:

score: 0
Accepted
time: 705ms
memory: 42988kb

input:

102 20 10
0101000100

output:

678899105

result:

ok 1 number(s): "678899105"

Test #83:

score: 0
Accepted
time: 18ms
memory: 39824kb

input:

97 16 13
0101110011010

output:

456291266

result:

ok 1 number(s): "456291266"

Subtask #3:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #84:

score: 30
Accepted
time: 466ms
memory: 44480kb

input:

66 20 5
11001

output:

286180948

result:

ok 1 number(s): "286180948"

Test #85:

score: 0
Accepted
time: 393ms
memory: 44236kb

input:

66 20 19
0101001111011100100

output:

334317215

result:

ok 1 number(s): "334317215"

Test #86:

score: 0
Accepted
time: 1619ms
memory: 53780kb

input:

66 22 19
1001101100000100001

output:

465510840

result:

ok 1 number(s): "465510840"

Test #87:

score: 0
Accepted
time: 1757ms
memory: 54868kb

input:

66 22 11
10001111000

output:

731812403

result:

ok 1 number(s): "731812403"

Test #88:

score: 0
Accepted
time: 244ms
memory: 5968kb

input:

66 24 6
011111

output:

270615978

result:

ok 1 number(s): "270615978"

Test #89:

score: 0
Accepted
time: 248ms
memory: 5972kb

input:

66 24 6
010001

output:

800866476

result:

ok 1 number(s): "800866476"

Test #90:

score: 0
Accepted
time: 199ms
memory: 6012kb

input:

66 26 11
01110011011

output:

292876310

result:

ok 1 number(s): "292876310"

Test #91:

score: 0
Accepted
time: 604ms
memory: 6024kb

input:

66 26 3
110

output:

269818127

result:

ok 1 number(s): "269818127"

Test #92:

score: 0
Accepted
time: 86ms
memory: 5884kb

input:

66 28 22
1111000101010111010110

output:

25687950

result:

ok 1 number(s): "25687950"

Test #93:

score: 0
Accepted
time: 509ms
memory: 5964kb

input:

66 28 7
0010101

output:

21960392

result:

ok 1 number(s): "21960392"

Test #94:

score: 0
Accepted
time: 177ms
memory: 5968kb

input:

66 30 16
1111000000011010

output:

599613456

result:

ok 1 number(s): "599613456"

Test #95:

score: 0
Accepted
time: 99ms
memory: 5880kb

input:

66 30 22
0010101110011001011100

output:

332331060

result:

ok 1 number(s): "332331060"

Test #96:

score: 0
Accepted
time: 208ms
memory: 6132kb

input:

66 32 12
011100101111

output:

692517940

result:

ok 1 number(s): "692517940"

Test #97:

score: 0
Accepted
time: 132ms
memory: 6172kb

input:

66 32 16
0100100100101001

output:

967944648

result:

ok 1 number(s): "967944648"

Test #98:

score: 0
Accepted
time: 477ms
memory: 44376kb

input:

65 20 1
1

output:

42155886

result:

ok 1 number(s): "42155886"

Test #99:

score: 0
Accepted
time: 394ms
memory: 43792kb

input:

65 20 17
10010110011011111

output:

178005033

result:

ok 1 number(s): "178005033"

Test #100:

score: 0
Accepted
time: 1593ms
memory: 54920kb

input:

65 22 16
0001011100100000

output:

785335838

result:

ok 1 number(s): "785335838"

Test #101:

score: 0
Accepted
time: 1717ms
memory: 55104kb

input:

65 22 13
1001101010101

output:

440523928

result:

ok 1 number(s): "440523928"

Test #102:

score: 0
Accepted
time: 462ms
memory: 6244kb

input:

65 24 0

output:

477090711

result:

ok 1 number(s): "477090711"

Test #103:

score: 0
Accepted
time: 76ms
memory: 6144kb

input:

65 24 14
10111111011101

output:

263900154

result:

ok 1 number(s): "263900154"

Test #104:

score: 0
Accepted
time: 229ms
memory: 6236kb

input:

65 26 10
1100111010

output:

343121911

result:

ok 1 number(s): "343121911"

Test #105:

score: 0
Accepted
time: 589ms
memory: 5964kb

input:

65 26 2
01

output:

1028654

result:

ok 1 number(s): "1028654"

Test #106:

score: 0
Accepted
time: 283ms
memory: 5972kb

input:

65 28 11
00010110101

output:

977003245

result:

ok 1 number(s): "977003245"

Test #107:

score: 0
Accepted
time: 78ms
memory: 5868kb

input:

65 28 25
1010000011011011000010010

output:

59779597

result:

ok 1 number(s): "59779597"

Test #108:

score: 0
Accepted
time: 257ms
memory: 5964kb

input:

65 30 12
011010110110

output:

28981686

result:

ok 1 number(s): "28981686"

Test #109:

score: 0
Accepted
time: 588ms
memory: 5936kb

input:

65 30 5
01111

output:

901067934

result:

ok 1 number(s): "901067934"

Test #110:

score: 0
Accepted
time: 204ms
memory: 5932kb

input:

65 32 9
101100011

output:

523898023

result:

ok 1 number(s): "523898023"

Test #111:

score: 0
Accepted
time: 58ms
memory: 6072kb

input:

65 32 31
1010100001010000110110000001000

output:

173664576

result:

ok 1 number(s): "173664576"

Test #112:

score: 0
Accepted
time: 467ms
memory: 43780kb

input:

64 20 2
10

output:

213928626

result:

ok 1 number(s): "213928626"

Test #113:

score: 0
Accepted
time: 386ms
memory: 44088kb

input:

64 20 17
01110111010001000

output:

629845990

result:

ok 1 number(s): "629845990"

Test #114:

score: 0
Accepted
time: 1871ms
memory: 54824kb

input:

64 22 4
0101

output:

755608618

result:

ok 1 number(s): "755608618"

Test #115:

score: 0
Accepted
time: 1491ms
memory: 54872kb

input:

64 22 20
00010010100011111010

output:

381748139

result:

ok 1 number(s): "381748139"

Test #116:

score: 0
Accepted
time: 160ms
memory: 5900kb

input:

64 24 9
100110100

output:

508203808

result:

ok 1 number(s): "508203808"

Test #117:

score: 0
Accepted
time: 51ms
memory: 8152kb

input:

64 24 17
11100000110000111

output:

271951917

result:

ok 1 number(s): "271951917"

Test #118:

score: 0
Accepted
time: 95ms
memory: 5964kb

input:

64 26 16
1100111111111110

output:

947719454

result:

ok 1 number(s): "947719454"

Test #119:

score: 0
Accepted
time: 77ms
memory: 6168kb

input:

64 26 18
101001101111101011

output:

557651914

result:

ok 1 number(s): "557651914"

Test #120:

score: 0
Accepted
time: 464ms
memory: 5968kb

input:

64 28 7
0011101

output:

659928242

result:

ok 1 number(s): "659928242"

Test #121:

score: 0
Accepted
time: 297ms
memory: 5976kb

input:

64 28 10
1100010011

output:

724166061

result:

ok 1 number(s): "724166061"

Test #122:

score: 0
Accepted
time: 664ms
memory: 5968kb

input:

64 30 2
10

output:

922542306

result:

ok 1 number(s): "922542306"

Test #123:

score: 0
Accepted
time: 643ms
memory: 5968kb

input:

64 30 2
10

output:

922542306

result:

ok 1 number(s): "922542306"

Test #124:

score: 0
Accepted
time: 75ms
memory: 6140kb

input:

64 32 14
00100000110010

output:

772135024

result:

ok 1 number(s): "772135024"

Test #125:

score: 0
Accepted
time: 56ms
memory: 5856kb

input:

64 32 19
0110111111001010010

output:

301836349

result:

ok 1 number(s): "301836349"

Test #126:

score: 0
Accepted
time: 32ms
memory: 5880kb

input:

66 48 10
1100101011

output:

250609010

result:

ok 1 number(s): "250609010"

Test #127:

score: 0
Accepted
time: 8ms
memory: 6072kb

input:

66 66 29
01110011011101001000011110101

output:

746018049

result:

ok 1 number(s): "746018049"

Test #128:

score: 0
Accepted
time: 4ms
memory: 42900kb

input:

66 14 7
1001101

output:

871164400

result:

ok 1 number(s): "871164400"

Test #129:

score: 0
Accepted
time: 426ms
memory: 5964kb

input:

66 24 1
0

output:

584525706

result:

ok 1 number(s): "584525706"

Test #130:

score: 0
Accepted
time: 389ms
memory: 5968kb

input:

66 24 2
11

output:

317970168

result:

ok 1 number(s): "317970168"

Test #131:

score: 0
Accepted
time: 648ms
memory: 5976kb

input:

66 26 1
0

output:

391681574

result:

ok 1 number(s): "391681574"

Test #132:

score: 0
Accepted
time: 599ms
memory: 5984kb

input:

66 26 2
00

output:

97862478

result:

ok 1 number(s): "97862478"

Test #133:

score: 0
Accepted
time: 916ms
memory: 5976kb

input:

66 28 1
0

output:

964005824

result:

ok 1 number(s): "964005824"

Test #134:

score: 0
Accepted
time: 843ms
memory: 5980kb

input:

66 28 2
11

output:

521812451

result:

ok 1 number(s): "521812451"

Test #135:

score: 0
Accepted
time: 125ms
memory: 6180kb

input:

57 24 10
0111100111

output:

275357201

result:

ok 1 number(s): "275357201"

Test #136:

score: 0
Accepted
time: 10ms
memory: 5852kb

input:

57 56 13
0111001000100

output:

712420784

result:

ok 1 number(s): "712420784"

Subtask #4:

score: 20
Accepted

Test #137:

score: 20
Accepted
time: 846ms
memory: 43180kb

input:

114 20 0

output:

849724285

result:

ok 1 number(s): "849724285"

Test #138:

score: 0
Accepted
time: 1610ms
memory: 5856kb

input:

114 22 0

output:

918046462

result:

ok 1 number(s): "918046462"

Test #139:

score: 0
Accepted
time: 552ms
memory: 5848kb

input:

114 24 0

output:

471169566

result:

ok 1 number(s): "471169566"

Test #140:

score: 0
Accepted
time: 523ms
memory: 5856kb

input:

114 26 0

output:

540055361

result:

ok 1 number(s): "540055361"

Test #141:

score: 0
Accepted
time: 192ms
memory: 5840kb

input:

114 28 0

output:

997530597

result:

ok 1 number(s): "997530597"

Test #142:

score: 0
Accepted
time: 81ms
memory: 5852kb

input:

114 30 0

output:

37439521

result:

ok 1 number(s): "37439521"

Test #143:

score: 0
Accepted
time: 95ms
memory: 5896kb

input:

114 32 0

output:

448438493

result:

ok 1 number(s): "448438493"

Test #144:

score: 0
Accepted
time: 837ms
memory: 43684kb

input:

113 20 0

output:

942733157

result:

ok 1 number(s): "942733157"

Test #145:

score: 0
Accepted
time: 1282ms
memory: 5808kb

input:

113 22 0

output:

547536565

result:

ok 1 number(s): "547536565"

Test #146:

score: 0
Accepted
time: 538ms
memory: 6108kb

input:

113 24 0

output:

219952878

result:

ok 1 number(s): "219952878"

Test #147:

score: 0
Accepted
time: 475ms
memory: 5752kb

input:

113 26 0

output:

763274765

result:

ok 1 number(s): "763274765"

Test #148:

score: 0
Accepted
time: 127ms
memory: 5824kb

input:

113 28 0

output:

910952876

result:

ok 1 number(s): "910952876"

Test #149:

score: 0
Accepted
time: 80ms
memory: 5840kb

input:

113 30 0

output:

968408969

result:

ok 1 number(s): "968408969"

Test #150:

score: 0
Accepted
time: 92ms
memory: 6108kb

input:

113 32 0

output:

118567934

result:

ok 1 number(s): "118567934"

Test #151:

score: 0
Accepted
time: 834ms
memory: 43892kb

input:

112 20 0

output:

275087743

result:

ok 1 number(s): "275087743"

Test #152:

score: 0
Accepted
time: 957ms
memory: 5840kb

input:

112 22 0

output:

185644824

result:

ok 1 number(s): "185644824"

Test #153:

score: 0
Accepted
time: 515ms
memory: 5840kb

input:

112 24 0

output:

557785519

result:

ok 1 number(s): "557785519"

Test #154:

score: 0
Accepted
time: 424ms
memory: 5848kb

input:

112 26 0

output:

522996775

result:

ok 1 number(s): "522996775"

Test #155:

score: 0
Accepted
time: 63ms
memory: 5844kb

input:

112 28 0

output:

134122652

result:

ok 1 number(s): "134122652"

Test #156:

score: 0
Accepted
time: 79ms
memory: 5840kb

input:

112 30 0

output:

502459554

result:

ok 1 number(s): "502459554"

Test #157:

score: 0
Accepted
time: 89ms
memory: 5844kb

input:

112 32 0

output:

169309797

result:

ok 1 number(s): "169309797"

Test #158:

score: 0
Accepted
time: 827ms
memory: 43996kb

input:

111 20 0

output:

360310827

result:

ok 1 number(s): "360310827"

Test #159:

score: 0
Accepted
time: 635ms
memory: 6056kb

input:

111 22 0

output:

516490684

result:

ok 1 number(s): "516490684"

Test #160:

score: 0
Accepted
time: 499ms
memory: 5860kb

input:

111 24 0

output:

501679698

result:

ok 1 number(s): "501679698"

Test #161:

score: 0
Accepted
time: 376ms
memory: 5892kb

input:

111 26 0

output:

43788136

result:

ok 1 number(s): "43788136"

Test #162:

score: 0
Accepted
time: 63ms
memory: 5852kb

input:

111 28 0

output:

5764962

result:

ok 1 number(s): "5764962"

Test #163:

score: 0
Accepted
time: 78ms
memory: 5836kb

input:

111 30 0

output:

918617250

result:

ok 1 number(s): "918617250"

Test #164:

score: 0
Accepted
time: 84ms
memory: 5848kb

input:

111 32 0

output:

982496307

result:

ok 1 number(s): "982496307"

Test #165:

score: 0
Accepted
time: 1ms
memory: 5852kb

input:

114 114 0

output:

321821768

result:

ok 1 number(s): "321821768"

Test #166:

score: 0
Accepted
time: 10ms
memory: 6120kb

input:

114 50 0

output:

860957763

result:

ok 1 number(s): "860957763"

Test #167:

score: 0
Accepted
time: 9ms
memory: 5844kb

input:

113 50 0

output:

307614098

result:

ok 1 number(s): "307614098"

Test #168:

score: 0
Accepted
time: 0ms
memory: 39704kb

input:

110 10 0

output:

615608372

result:

ok 1 number(s): "615608372"

Test #169:

score: 0
Accepted
time: 0ms
memory: 5856kb

input:

100 50 0

output:

475715516

result:

ok 1 number(s): "475715516"

Test #170:

score: 0
Accepted
time: 1ms
memory: 5844kb

input:

111 78 0

output:

617855013

result:

ok 1 number(s): "617855013"

Test #171:

score: 0
Accepted
time: 46ms
memory: 5852kb

input:

100 26 0

output:

960228335

result:

ok 1 number(s): "960228335"

Test #172:

score: 0
Accepted
time: 53ms
memory: 5824kb

input:

99 28 0

output:

17612739

result:

ok 1 number(s): "17612739"

Test #173:

score: 0
Accepted
time: 64ms
memory: 5820kb

input:

107 28 0

output:

462764365

result:

ok 1 number(s): "462764365"

Subtask #5:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

100%
Accepted

Test #174:

score: 30
Accepted
time: 755ms
memory: 44644kb

input:

114 20 18
010001110011101110

output:

431763994

result:

ok 1 number(s): "431763994"

Test #175:

score: 0
Accepted
time: 784ms
memory: 44116kb

input:

114 20 12
110101100011

output:

470786738

result:

ok 1 number(s): "470786738"

Test #176:

score: -30
Time Limit Exceeded

input:

114 22 7
1100100

output:


result: