Universal Cup Judging System

Universal Cup

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

你有一個可以顯示 $n$ 位整數嘅 LED 顯示屏,其中每個數碼都係用標準嘅 $7$ 段數碼管佈局嚟表示。

7-segment display

最初,每個數碼塊入面嘅 $7$ 個數碼段都可能處於以下三種狀態之一:

  • 正常(用 W 表示):表現正常,即係根據要顯示嘅數字按需要亮起或者熄滅;
  • 卡喺常亮(用 1 表示):無論顯示咩數字,都一直保持亮起;
  • 卡喺常滅(用 0 表示):無論顯示咩數字,都一直保持熄滅。

你最多可以翻新 $k$ 個數碼段,即係將最多 $k$ 個數碼段轉換成正常狀態。你需要最大化能夠正確顯示嘅整數數量,並求出達到呢個最大值嘅方案數。請注意,你亦可以翻新原本已經係正常狀態嘅數碼段,而且每個數碼段最多只能夠翻新一次。如果存在至少一個數碼段喺其中一種方案入面被翻新、而喺另一種方案入面冇被翻新,噉呢兩種翻新方案就視為唔同。

一個整數能夠被正確顯示,當且僅當滿足以下所有條件:

  • 除非該整數恰好係 $0$,否則佢冇前導零;
  • 佢喺顯示屏上係靠右對齊嘅:如果該整數有 $d$($1 \le d \le n$)位,噉就只會用到最右邊嘅 $d$ 個數碼塊,而最左邊嘅 $(n - d)$ 個數碼塊應該留空(乜都唔顯示);
  • 對於用到嘅 $d$ 個數碼塊入面嘅每一個,當正常嘅數碼段顯示該數字對應嘅正確狀態、而故障嘅數碼段保持卡死喺自身狀態嗰陣,全部 $7$ 個數碼段都同目標數字嘅顯示圖案完全一致。

輸入

輸入嘅第一行包含一個整數 $T$($1 \le T \le 100$),代表測試數據嘅組數。對於每組測試數據:

第一行包含兩個整數 $n$($1 \le n \le 9$)同埋 $k$($0 < k < 7n$),分別代表 LED 顯示屏可以顯示嘅位數,同埋你可以修復嘅數碼段數量。

接下來 $7$ 行,每行包含一個長度恰好為 $(5n - 1)$ 個字符嘅字符串,以 ASCII 圖像嘅形式描述 LED 顯示屏嘅初始狀態。

顯示屏由 $n$ 個數碼塊組成,每個數碼塊佔 $4$ 列,之間由單列嘅空隙隔開。所有數碼段都由兩個相同嘅字符(W、0 或 1)表示,而其他所有位置都填入純粹用嚟排版嘅字符 .。詳情請參閱範例輸入同埋提示。

輸出

對於每組測試數據,輸出一行包含兩個整數,分別代表翻新最多 $k$ 個數碼段後能夠正確顯示嘅最大整數數量,以及達到該最大值嘅方案數。

範例

範例輸入 1

2
3 2
.00...00...00.
0..0.0..0.0..1
0..0.0..0.0..1
.00...00...00.
0..W.0..0.0..1
0..W.0..0.0..1
.00...00...00.
9 62
.WW...WW...WW...WW...WW...WW...WW...WW...WW.
W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W
W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W
.WW...WW...WW...WW...WW...WW...WW...WW...WW.
W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W
W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W.W..W
.WW...WW...WW...WW...WW...WW...WW...WW...WW.

範例輸出 1

2 23
1000000000 9223372036854775807

提示

喺以 ASCII 圖像形式表示嘅 LED 顯示屏嘅每個數碼塊入面,各個數碼段如下:

數碼段 部位 位置(行, 列)
$0$ 頂部橫段 $(1, 2), (1, 3)$
$1$ 左上豎段 $(2, 1), (3, 1)$
$2$ 右上豎段 $(2, 4), (3, 4)$
$3$ 中間橫段 $(4, 2), (4, 3)$
$4$ 左下豎段 $(5, 1), (6, 1)$
$5$ 右下豎段 $(5, 4), (6, 4)$
$6$ 底部橫段 $(7, 2), (7, 3)$

數字 $0, 1, 2, \dots, 9$ 嘅顯示圖案($1$ = 亮起,$0$ = 熄滅)如下:

數字 圖案(數碼段 $0, 1, 2, \dots, 6$) 說明
$0$ 1110111 除中間外全部亮起
$1$ 0010010 右上同埋右下
$2$ 1011101 頂部、右上、中間、左下同埋底部
$3$ 1011011 頂部、右上、中間、右下同埋底部
$4$ 0111010 左上、右上、中間同埋右下
$5$ 1101011 頂部、左上、中間、右下同埋底部
$6$ 1101111 除右上外全部亮起
$7$ 1010010 頂部、右上同埋右下
$8$ 1111111 全部數碼段亮起
$9$ 1111011 除左下外全部亮起

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.