Codeforces Round 705 (Div. 2)
E
Enormous XOR
Codeforces
2600
原题
← DF →
翻译中…

You are given two integers $l$ and $r$ in binary representation. Let $g(x, y)$ be equal to the bitwise XOR of all integers from $x$ to $y$ inclusive (that is $x \oplus (x+1) \oplus \dots \oplus (y-1) \oplus y$). Let's define $f(l, r)$ as the maximum of all values of $g(x, y)$ satisfying $l \le x \le y \le r$.

翻译中…

Output $f(l, r)$.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 10^6$) — the length of the binary representation of $r$.

翻译中…

The second line contains the binary representation of $l$ — a string of length $n$ consisting of digits $0$ and $1$ ($0 \le l \lt 2^n$).

翻译中…

The third line contains the binary representation of $r$ — a string of length $n$ consisting of digits $0$ and $1$ ($0 \le r \lt 2^n$).

翻译中…

It is guaranteed that $l \le r$. The binary representation of $r$ does not contain any extra leading zeros (if $r=0$, the binary representation of it consists of a single zero). The binary representation of $l$ is preceded with leading zeros so that its length is equal to $n$.

翻译中…

Output

翻译中…

In a single line output the value of $f(l, r)$ for the given pair of $l$ and $r$ in binary representation without extra leading zeros.

翻译中…

Note

翻译中…

In sample test case $l=19$, $r=122$. $f(x,y)$ is maximal and is equal to $127$, with $x=27$, $y=100$, for example.

翻译中…

样例

Input #1
7
0010011
1111010
Output #1
1111111
InputCopy OutputCopy
Input #2
4
1010
1101
Output #2
1101
InputCopy OutputCopy
题目信息
题号
1493E
时间限制
1 s
内存限制
256 MB
标签
位运算
构造
贪心
数学
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。