eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Digital Content Protection

Digital Content Protection

\includegraphics{https://static.e-olymp.com/content/c7/c76ea38e4503272582ae09b69ff530f22e52da74.jpg} Dan is working for a digital content protection company, which is responsible for the content protection of blu-ray discs based on a standard called Anti Content Misuse (ACM). The ACM standard works as follows. Assume there are \textbf{2^n} blu-ray drives/players. We represent these \textbf{2^n} drives as the leaves of a complete binary tree of height \textbf{n}, so that each root-to-leaf path consists of \textbf{n} edges. Each node \textbf{u} in this binary tree is assigned an identifier number and contains a random key \textbf{k_u}. The identifier numbers are assigned as follows. The root, \textbf{r}, is assigned \textbf{1}. In addition, the left and right children of an internal node having number \textbf{i} are assigned numbers \textbf{2i} and \textbf{2i+1}, respectively. This scheme assigns a distinct number to each node in the tree. The keys contained in the nodes are unknown to blu-ray users, but they are available to blu-ray drive manufacturers. Each blu-ray player is assigned the identifier number \textbf{i} (\textbf{2^n} ≤ \textbf{i} ≤ \textbf{2^\{n+1\}−1}) of its corresponding leaf in the tree. A manufacturer of blu-ray drives embeds the keys associated with the nodes in the path from the root to leaf number \textbf{i} in player number \textbf{i}. To encrypt the content of a blu-ray disc, the company in charge creates a random key \textbf{k} called the master key. First, they encrypt \textbf{k} with the key \textbf{k_r} (recall \textbf{r} is the root node of binary tree) and write it on the disc as a header. Then, they encrypt the content with \textbf{k}, and write the encrypted data on the blu-ray disc. A blu-ray drive first decrypts the header using key \textbf{k_r} embedded in it and recovers the master key \textbf{k} and then, decrypts the content using the key \textbf{k}. \includegraphics{https://static.e-olymp.com/content/a0/a01d6fe5baf86fd274dfc5600a30f76cc672dd3c.jpg} Unfortunately, the keys embedded in a set of blu-ray drives, \textbf{R}, are exposed by hackers and published on the web. As a result, we cannot encrypt the master key \textbf{k} using any of these exposed keys. For example, since all blu-ray drives contain \textbf{k_r}, the encryption scheme above does not work any more. There is a solution oversaw for this situation in the ACM standard. At the cost of a larger header, the industry can safely encrypt the content of a new blu-ray disc. They carefully choose a subset of unexposed keys \textbf{K} in the binary tree such that all blu-ray drives, except for drives in \textbf{R}, have at least one of the keys in \textbf{K}. They encrypt the master key \textbf{k} with each key \textbf{k'} \textbf{K} and put the result in the header (i.e., there are \textbf{|K|} ciphertexts in the header). Now, each active blu-ray drive can decrypt at least one of the ciphertexts in the header and can recover the master key \textbf{k}. Dan needs your help to determine a subset of keys \textbf{K} with minimum cardinality (which results in the smallest header) given the identifiers of hacked drives. \InputFile The input consists of a single test case. A test case consists of two lines. The first line contains two integers \textbf{n} and \textbf{|R|}, where \textbf{1} ≤ \textbf{n} ≤ \textbf{62} and \textbf{1} ≤ \textbf{|R|} ≤ \textbf{1000}. \textbf{|R|} is the cardinality of \textbf{R}, the set of exposed drives. The second line contains \textbf{|R|} integers, which are the identifiers of exposed blu-ray drives. You can assume that there is at least one blu-ray drive not hacked. \OutputFile Display the identifiers of nodes corresponding to the keys in \textbf{K}, satisfying the above requirements and having minimum cardinality, in increasing order and separated with single spaces.
Ліміт часу 2 секунди
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2 1
5
Вихідні дані #1
3 4
Джерело 2013 Rocky Mountain Regional ACM Contest