{"problem":{"name":"Differ by K bits","description":{"content":"You are given integers $N$ and $K$. Determine whether there exists a permutation $P=(P_0,P_1,\\cdots,P_{2^N-1})$ of $(0,1,\\cdots,2^N-1)$ satisfying the condition below, and construct one such sequence ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc138_d"},"statements":[{"statement_type":"Markdown","content":"You are given integers $N$ and $K$. Determine whether there exists a permutation $P=(P_0,P_1,\\cdots,P_{2^N-1})$ of $(0,1,\\cdots,2^N-1)$ satisfying the condition below, and construct one such sequence if it exists. Note that $P$ is $0$\\-indexed.\n\n*   For every $i$ ($0 \\leq i \\leq 2^N-1$), $P_i$ and $P_{i+1 \\mod 2^N}$ differ by exactly $K$ bits in binary representation. The comparison is made after zero-padding both integers to $N$ bits.\n\n## Constraints\n\n*   $1 \\leq K \\leq N \\leq 18$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc138_d","tags":[],"sample_group":[["3 1","Yes\n0 1 3 2 6 7 5 4\n\nHere, we have $P=(000,001,011,010,110,111,101,100)$ in binary representation.\nWe can see that $P_1=001$ and $P_2=011$, for example, differ by exactly $1$ bit, satisfying the condition for $i=1$. The same goes for every $i$."],["2 2","No"]],"created_at":"2026-03-03 11:01:13"}}