All submissions for this problem are available.
Thakur finally decided to tell a poem to his girlfriend on phone to impress her. But being a geeky coder, he thinks a good poem is one that only has a number containing digits 1 or 2 only. So only numbers like 112, 12222 forms a good poem and not 1134, 8222 etc.
Now Thakur's girlfriend is also very meticulous about the poem. She has given some demands on the number Thakur is going to recite in the poem. Demands are in form of number of occurrences of substring "1","2","12","21" in the poem as d1,d2,d3,d4 respectively. For example - if poem is "22221111" d1 = 4 , d2 = 4, d3 = 0 ,d4 = 1.
Given the demands, help Thakur finding SMALLEST such number that he can recite in the poem.
The first line of the input contains number t – the amount of tests. Then t test descriptions follow. The first line of each test contains four integers d1,d2,d3,d4 - the four demands on the poem.
- 1 <= t <= 10
- 1 <= d1,d2,d3,d4 <= 10^6
For each test case, the SMALLEST number that fullfill all the demands. If no such number exists, print "SORRY THAKUR!" (without quotes).
3 2 2 1 1 4 7 3 1 2 3 1 2
1221 SORRY THAKUR! 21221
|Time Limit:||4 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, GO, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.