2175 - I2P(I)2020_Yang_HW9 Scoreboard

Time

2020/11/17 21:00:00 2020/11/24 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11222 N queens
12460 Little Brick's Choice
12987 Let's build a hacker script

11222 - N queens   

Description

You have to place N queens on a NxN chessboard in such a way that no queen threatens another one

The rule is that each row and column of the board contains exactly 1 queen , and each diagonal contains no more than 1 queen.

Your mission is to compute how many possible ways to place N queens on that chessboard.

Input

An integer N which represent the size of chessboard and the number of queens.

where 1<=N<=10

Output

An integer which represent the number of possible distributions of  N queens.

There is no need to add '\n' at the end of output

Sample Input  Download

Sample Output  Download

Tags




Discuss




12460 - Little Brick's Choice   

Description

Little Brick(小磚頭) once wanted to register an account on a webpage,
however, he didn't know what password he should use,

he wanted his password in increasing ASCII code order,
and he listed some characters that he wanted to use in the password,
can you show all possible passwords that he can choose.

That is, a valid password must contain 4 or more characters and be in an increasing order of ASCII code,
Every character in the list can only be used once.
You must list all possible passwords in lexicographical order.

ouo.

Lexicographical Order: Given two different sequences, if two words have the same first letter, we compare the second. If the second letters are the same, we compare the third, etc. Finally, one word comes before the other if the first differing letter comes before the corresponding letter. If two words are identical up to the length of the shorter word, the shorter word comes first.

For example, if the input is "acebd", then you should output
abcd, abcde, abce, abde, acde, bcde
Note that "abed" is not valid since characer 'e' should be after 'd',
and "abd" is not a valid password too because its length is only 3.

Note that the ASCII codes for 'A'-'Z' are 65-90 and for 'a'-'z' are 97-122.

Input

Input contains only 1 line, representing the list of some characters that can be used in the password.

It is guaranteed that the characters will not be duplicated,
and 4 <= length of the given list <= 18, and the characters will only be lowercase or uppercase alphabet.

Output

Output contains only one line.

List all possible passwords in lexicographical order, separated by ", " (without quotes)

Remember to add a newline character after your output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12987 - Let's build a hacker script   

Description

As a student studying in computer science,

your parents and your friends always think of you as a hacker.

 

To impress them, you want to build a hacker script.

After several days of scripting, you finally got the system's administration password.

 

But the system has a protection mechanism,

which replace some consecutive letters into a '#' character as the system settings.

After that, there may be one or more '#' character,

and each '#' character represent one to many arbitary letters.

 

To get the whole control of the system,

you must know the exactly characters replaced by each '#' character.

 

Now, your goal is to print all possible combinations of each '#' character.

For the output order, please refer to the sample I/O.

 

The output order is also formally defined as follows.

Assume that the password you get is a string S,

and S[L, R] represent the substring from Lth character to the Rth character of string S.

For any 2 possible combinations A and B,

if the ith '#' in combination A replaced S[ALi, ARi] to '#',

the ith '#' in combination B replaced S[BLi, BRi] to '#',

and for the smallest i that ALi ≠ BLi and ARi ≠ BRi,

if ALi < BLi or (ALi = BLi and ARi < BRi),

then combination A should be output before combination B,

otherwise the combination B should be output before combination A.

If there is no any possible combinations,

output "What the hack!?" (without quotes).

 

ouo.

Input

Input contains 2 lines.

There first line contains a string S, represent the password of the system.

The second line contains a string P, represent the string you get after the protection mechanism replaced some character from S to '#'.

 

It is guaranteed that:

1 <= |S| <= 20, and S contains only lowercase letters,

1 <= |P| <= 20, and P contains only lowercase letters and at least 1 character '#'.

Output

If there is any possibles combination,

output one line per combination,

and separate the representation of each '#' by spaces.

Notice that the output order of combinations should follow the rules in the description.

 

If there is no any possible combination,

output "What the hack!?" (Without quotes)

Sample Input  Download

Sample Output  Download

Tags




Discuss