길이 2^(2w+1)인 이진 규칙 문자열 p 중 s 이상이면서, (w,p) 셀 오토마타에서 1의 개수가 항상 보존되게 하는 사전순 최소 p를 구한다.
어려움9수학조합론완전 탐색비트 연산아직 제출이 없습니다시간 제한1초메모리 제한512 MBLet w be a positive integer and p be a string of length 22w+1. (w, p)− cell automaton is defined as follows:
\[f(t,x) = p[\sum_{i=-w}^{w}{2^{w+i}f(t-1,x+i)}]\]
Snuke likes a cell automaton if the number of 1 doesn’t change forever (no matter how he chooses the states at time 0). You are given an integer w and a string s. Compute the lexicographically minimal p such that s ≤ p and Snuke likes (w, p)− cell automaton.
First line of the input contains one integer w (1 ≤ w ≤ 3). Next line contains string s (|s| = 22w+1, s consists of ‘0’ and ‘1’.
Print the minimal possible p. If there are no such strings, print “no” instead.