2474 - I2P(II)2022_Yang_lab0 Scoreboard

Time

2022/02/18 13:20:00 2022/02/18 15:45:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12602 OuQ String
12604 N-Queens M-Rooks Problem

12602 - OuQ String   

Description

Define the level 1 string s1 = “OuQ”,
and the level k string sk = “O” + sk1 + “u” + sk1 + “Q”.

For example:

  • s2 = “O” + s1 + “u” + s1 + “Q” = “OOuQuOuQQ”
  • s3 = “OOOuQuOuQQuOOuQuOuQQQ”

Given 3 integeres k,l,r.
Please find all characters of sk[l],sk[l+1],...sk[r1],sk[r]

Input

There’re multiple testcases in input.
Three integers k,l,r on each line.

  • ≤ ≤ 50
  • ≤ ≤ length of sk
  • ≤ |rl+1≤ 100

Output

For each testcase, print |rl+1| characters,sk[l],sk[l+1],...sk[r1],sk[r], for a line.

Remember ‘\n’ on the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12604 - N-Queens M-Rooks Problem   

Description

N queens problem asks how many ways to place N non-attacking queens on an N×N chessboard.

For example, there’re 2 solutions for N = 4:
( 0 means empty spot, Q means queen. )

0 Q 0 0     0 0 Q 0
0 0 0 Q     Q 0 0 0
Q 0 0 0     0 0 0 Q
0 0 Q 0     0 Q 0 0

While, there’s no solution for N = 2:
Below is the all placements. All of them contains queens threaten each other.

Q Q    Q 0    Q 0    0 Q    0 Q    0 0
0 0    Q 0    0 Q    Q 0    0 Q    Q Q

Let’s define a new problem “N-Queens M-Rooks Problem”.
It asks how many ways to place N queens and M rooks on an (N+M)×(N+M)( chessboard such that no two of queens or rooks can attack each other in 1 step.

For N = 1, M = 2, there’re 4 solutions:
( 0 means empty spot, Q means queen, R means rook. )

Q 0 0    0 R 0
0 0 R    R 0 0
0 R 0    0 0 Q

0 R 0    0 0 Q
0 0 R    R 0 0
Q 0 0    0 R 0

Possible move of Queen:

Possible move of Rook:

Input

There’re multiple testcases.
Each testcase is consisted of 2 integers N,M on one line.

It’s guaranteed that:

  • ≤ N≤ 9
  • ≤ N+≤ 9

Output

Print the number of solution for N-Queens M-Rooks Problem for every testcase.
Remember ‘\n’ on the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss