29 1 s 128 MB
A computer connected to the internet is identified by an IP address. The most common way of displaying an IP address is the dotted quad method: four eight-bit (0-255 in base ten) numbers separated by periods.
Someone has given you a possible IP address, but the periods have been removed, leaving only a string of digits. IP Converter with a method possible Addresses that takes a String ambiguous IP containing the digits and prints a String containing all the possible IP addresses that can be formed from those digits by inserting three periods to form a dotted quad.
The numbers in each of the four positions can have any integer value between zero and 255, inclusive. However, a number may not have leading zeroes. For example, the digits 1902426 can form 220.127.116.11, 18.104.22.168, 22.214.171.124, and other IP addresses. However, it cannot form 19.02.4.26.
First line, a number of test cases T( T <= 50)
Next line, ambiguous IP will contain between 1 and 50 characters.
Each character of ambiguous IP will be between '0' and '9', inclusive.
Print value lexicographically, the elements of the all possible IP addresses, using their string ordering (the period character precedes all digit characters).
if you cannot find possible IP addresses, print the IMPOSSIBLE.
End of each test case, print the newline.
4 1902426 000 11111111 3082390871771742784899852251737850570843857369760
126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 IMPOSSIBLE 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11 18.104.22.168 22.214.171.124 126.96.36.199 188.8.131.52 IMPOSSIBLE