GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Tuesday 28 June 2022

[Solution] Long Binary String Codeforces Solution | Codeforces Problem Solution 2022


G. Long Binary String
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There is a binary string t of length 10100, and initally all of its bits are 0. You are given a binary string s, and perform the following operation some times:

  • Select some substring of t, and replace it with its XOR with s.
After several operations, the string t has exactly two bits 1; that is, there are exactly two distinct indices p and q such that the p-th and q-th bits of t are 1, and the rest of the bits are 0.

Find the lexicographically largest string t satisfying these constraints, or report that no such string exists.

 Formally, choose an index i such that 0i10100|s|. For all 1j|s|, if sj=1, then toggle ti+j. That is, if ti+j=0, set ti+j=1. Otherwise if ti+j=1, set ti+j=0.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

 A binary string a is lexicographically larger than a binary string b of the same length if in the first position where a and b differ, the string a has a bit 1 and the corresponding bit in b is 0.

Output

If no string t exists as described in the statement, output -1. Otherwise, output the integers p and q (1p<q10100) such that the p-th and q-th bits of the lexicographically maximal t are 1.

No comments:

Post a Comment