문제2326--IP Converter

2326: IP Converter

실행시간 제한: 1 Sec  메모리사용 제한: 128 MB  Special Judge
제출: 96  통과: 45
[제출] [채점기록] [묻고답하기]

문제 설명

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 1.90.24.26, 19.0.24.26, 190.2.4.26, 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.

입력 예시 Copy

4
1902426
000
11111111
3082390871771742784899852251737850570843857369760

출력 예시 Copy

1.90.24.26
1.90.242.6
19.0.24.26
19.0.242.6
190.2.4.26
190.2.42.6
190.24.2.6

IMPOSSIBLE 

1.1.111.111
1.11.11.111
1.11.111.11
1.111.1.111
1.111.11.11
1.111.111.1
11.1.11.111
11.1.111.11
11.11.1.111
11.11.11.11
11.11.111.1
11.111.1.11
11.111.11.1
111.1.1.111
111.1.11.11
111.1.111.1
111.11.1.11
111.11.11.1
111.111.1.1

IMPOSSIBLE

출처/분류