{"problem":{"name":"J. palprime","description":{"content":"A palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Palindromicity depends on the base of the numbering system and its writing conventions, while pri","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":4000,"memory_limit":24576},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10088J"},"statements":[{"statement_type":"Markdown","content":"A palindromic prime (sometimes called a palprime) is a prime number that is also a palindromic number. Palindromicity depends on the base of the numbering system and its writing conventions, while primality is independent of such concerns. \n\nThe sequence of binary palindromic primes begins(in binary): \n\n11, 101, 111, 10001, 11111, 1001001 You are given a number b (in binary), you should output the first palprime greater than or equal to b. \n\nThe input consists of multiple test cases, each test case consists of a number b in binary. \n\nWe guarantee b will be no Longer than 21 bits\n\nThe first palprime greater than or equal to b\n\n## Input\n\nThe input consists of multiple test cases, each test case consists of a number b in binary. We guarantee b will be no Longer than 21 bits\n\n## Output\n\nThe first palprime greater than or equal to b\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T = (V, E, w) $ be a weighted undirected tree with $ |V| = N $, where $ w: E \\to \\mathbb{Z}^+ $ is the edge weight function.  \nLet $ S \\subseteq V $ be a dynamic subset of \"special\" cities.  \n\n**Constraints**  \n1. $ 1 \\leq N \\leq 10^5 $  \n2. $ 1 \\leq Q \\leq 10^5 $  \n3. Total sum of $ |S| $ over all type-2 queries $ \\leq 5 \\cdot 10^5 $  \n4. Edge weights $ w(e) \\in [1, 10^9] $  \n\n**Operations**  \n- **Type 1**: Toggle membership of a city $ c \\in V $ in $ S $:  \n  $ S \\leftarrow S \\oplus \\{c\\} $  \n- **Type 2**: Given $ S $, for each $ v \\in S $, compute:  \n  $$\n  f(v) = \\max_{u \\in S \\setminus \\{v\\}} \\text{dist}(v, u)\n  $$  \n  where $ \\text{dist}(v, u) $ is the sum of edge weights along the unique path between $ v $ and $ u $ in $ T $.  \n\n**Objective**  \nFor each type-2 query, output $ f(v) $ for every $ v \\in S $ in the order given in the query.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10088J","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}