GUPTA MECHANICAL

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

Thursday, 16 June 2022

[Solution] Creep Codeforces Solution 


Define the score of some binary string T as the absolute difference between the number of zeroes and ones in it. (for example, T= 010001 contains 4 zeroes and 2 ones, so the score of T is |42|=2).

Define the creepiness of some binary string S as the maximum score among all of its prefixes (for example, the creepiness of S= 01001 is equal to 2 because the score of the prefix S[14] is 2 and the rest of the prefixes have a score of 2 or less).

Solution Click Below:-  CLICK HERE

Given two integers a and b, construct a binary string consisting of a zeroes and b ones with the minimum possible creepiness.

Input

The first line contains a single integer t (1t1000)  — the number of test cases. The description of the test cases follows.

The only line of each test case contains two integers a and b (1a,b100)  — the numbers of zeroes and ones correspondingly.

Output

For each test case, print a binary string consisting of a zeroes and b ones with the minimum possible creepiness. If there are multiple answers, print any of them.

No comments:

Post a Comment