CF1493E.Enormous XOR

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

Output f(l,r)f(l, r).

给你两个以二进制形式给出的整数 ll 和 rr。定义函数 g(x,y)g(x, y) 为从 xx 到 yy(含端点)所有整数的按位异或结果(即 x⊕(x+1)⊕⋯⊕(y−1)⊕yx \oplus (x+1) \oplus \dots \oplus (y-1) \oplus y)。再定义 f(l,r)f(l, r) 为所有满足 l≤x≤y≤rl \le x \le y \le r 的 g(x,y)g(x, y) 中的最大值。

输出 f(l,r)f(l, r)。

输入格式

The first line contains a single integer nn (1≤n≤1061 \le n \le 10^6) — the length of the binary representation of rr.

The second line contains the binary representation of ll — a string of length nn consisting of digits 00 and 11 (0≤l<2n0 \le l \lt 2^n).

The third line contains the binary representation of rr — a string of length nn consisting of digits 00 and 11 (0≤r<2n0 \le r \lt 2^n).

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

第一行包含一个整数 nn(1≤n≤1061 \le n \le 10^6)——即 rr 的二进制表示的长度。

第二行包含 ll 的二进制表示——一个长度为 nn 的字符串,仅由数字 00 和 11 组成(满足 0≤l<2n0 \le l \lt 2^n)。

第三行包含 rr 的二进制表示——一个长度为 nn 的字符串,仅由数字 00 和 11 组成(满足 0≤r<2n0 \le r \lt 2^n)。

保证 l≤rl \le r。rr 的二进制表示不含多余的前导零(若 r=0r=0,则其二进制表示为单个字符 0)。ll 的二进制表示在前面补足了前导零,使其长度恰好为 nn。

输出格式

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

在一行中输出给定 ll 和 rr 对应的 f(l,r)f(l, r) 的值,以二进制形式表示,不带额外前导零。

输入输出样例

  • 输入#1

    7
    0010011
    1111010

    输出#1

    1111111
  • 输入#2

    4
    1010
    1101

    输出#2

    1101

说明/提示

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

在样例测试用例中,l=19l=19,r=122r=122。f(x,y)f(x,y) 取得最大值 127127,例如当 x=27x=27、y=100y=100 时。

输入解题思路,AI测评打分。不知道怎么写?

首页