{"problem":{"name":"B. Working with Locks 2","description":{"content":"104 days of summer vacation and school comes along just to end it! For the rest of summer vacation, Dr. Doofenshmirtz will occasionally be doing things to take over the Greater Tri-State Area and Perr","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10253B"},"statements":[{"statement_type":"Markdown","content":"104 days of summer vacation and school comes along just to end it! For the rest of summer vacation, Dr. Doofenshmirtz will occasionally be doing things to take over the Greater Tri-State Area and Perry the Platypus has to stop him.\n\nThe good news is that Agent P has managed to make an imprint of a set of keys and duplicate all of them. The bad news is that each day, Perry will be locked inside a different room with a different lock. And the set of keys he has might not have a correct key to open the lock on some days.\n\nThere are a total of 104 different locks, one for each day of summer vacation, and there are 104 different keys. As before, each key can open a lock if the difference between their numbers is exactly one. To be more explicit:\n\nYou will be given the set of keys that Perry the Platypus has as well as the lock numbers on the days that Dr. Doofenshmirtz will be active.\n\nOutput how many days Perry can successfully stop the mad doctor.\n\nEach test case consists of four lines.\n\nThe first line contains an integer $k$, the number of keys that Perry has.\n\nThe second line contains $k$ space-separated integers representing each key $k_i$.\n\nThe third line contains an integer $L$, the number of locks.\n\nThe fourth line contains $L$ space-separated integers, representing each lock $L_i$.\n\n*Constraints*\n\n$1 <= k <= 104$ \n\n$1 <= k_i <= 104$ \n\n$1 <= L <= 104$ \n\n$1 <= L_i <= 104$ \n\nNo two $k_i$s are the same. \n\nNo two $L_i$s are the same. \n\nOutput a single integer, the number of days that Perry can successfully stop Dr. Doofenshmirtz.\n\n## Input\n\nEach test case consists of four lines.The first line contains an integer $k$, the number of keys that Perry has.The second line contains $k$ space-separated integers representing each key $k_i$.The third line contains an integer $L$, the number of locks.The fourth line contains $L$ space-separated integers, representing each lock $L_i$.*Constraints*$1 <= k <= 104$ $1 <= k_i <= 104$ $1 <= L <= 104$ $1 <= L_i <= 104$ No two $k_i$s are the same. No two $L_i$s are the same. \n\n## Output\n\nOutput a single integer, the number of days that Perry can successfully stop Dr. Doofenshmirtz.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of craters and days.  \nLet $ m \\in \\mathbb{Z}^+ $ be the number of craters Roro visits per day.  \nLet $ S = (s_1, s_2, \\dots, s_n) \\in \\{0,1\\}^n $ be the initial state of craters, where $ s_i = 1 $ means open, $ s_i = 0 $ means filled.  \n\nLet $ D = (d_1, d_2, \\dots, d_n) $ be a sequence of day-wise commands, where each $ d_k \\subseteq \\{1, 2, \\dots, n\\} $ with $ |d_k| = m $, denotes the set of craters visited on day $ k $.  \n\n**Constraints**  \n1. $ 1 \\leq t \\leq 1000 $  \n2. For each test case:  \n   - $ 1 \\leq n \\leq 20 $  \n   - $ 1 \\leq m \\leq n $  \n   - $ s_i \\in \\{0,1\\} $ for all $ i \\in \\{1, \\dots, n\\} $  \n\n**Dynamics**  \nLet $ c_k = (c_{k,1}, \\dots, c_{k,n}) \\in \\{0,1\\}^n $ be the state of craters at the end of day $ k $, with $ c_0 = S $.  \nFor each day $ k \\in \\{1, \\dots, n\\} $:  \n- For each crater $ i \\in \\{1, \\dots, n\\} $:  \n  $$\n  c_{k,i} = \n  \\begin{cases}\n  0 & \\text{if } i \\in d_k \\text{ and } c_{k-1,i} = 0 \\\\\n  1 & \\text{if } i \\in d_k \\text{ and } c_{k-1,i} = 1 \\\\\n  c_{k-1,i} & \\text{otherwise}\n  \\end{cases}\n  $$  \n  (i.e., visiting a filled crater opens it; visiting an open crater fills it.)  \n\n**Objective**  \nFind a sequence $ D = (d_1, \\dots, d_n) $ such that $ c_n = (0, 0, \\dots, 0) $, or determine that no such sequence exists.  \n\nIf impossible: output \"_CATACLYSM IMMINENT - TIME TO HOARD FACE MASKS_\"  \nOtherwise: output $ n $ lines, each containing $ m $ distinct integers (1-indexed) representing $ d_k $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10253B","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}