Public Judge

pjudge

時間限制: 2 s 記憶體限制: 512 MB 總分: 100

#21946. 【PR #16】CD Shuffle

统计

This is an interactive problem.

You have purchased a CD set containing $N$ episodes of My Little Pony. Each CD has a label numbered from $1$ to $N$, but the actual episode number stored on each CD does not match its label. It is known that:

  1. All episodes from $1$ to $N$ are present and unique.
  2. The mapping between CD label numbers $1$ to $N$ and episode numbers is a permutation.

You need to determine the actual episode number corresponding to each CD label through several rounds of interaction. Each round of interaction proceeds as follows:

  1. Grouping Phase: Divide the $N$ CDs into $B$ boxes, with each box containing $K$ CDs (it is guaranteed that $N = B \times K$).
  2. Sending Phase: Send the grouped CDs to your friend, L.
    • The order of the boxes will be shuffled.
    • The order of the CDs within each box will also be shuffled.
  3. Receiving Phase: L will:
    • Observe the actual episode numbers of the CDs in each box.
    • Return the results in an arbitrary order (the original grouping information is not preserved).

You may perform at most $Q$ such interactions. After the interactions are complete, you must determine the episode number corresponding to each CD label.

Implementation Details

You need to implement the following function:

vector<int> solve(int N, int B, int K, int Q, int ST)

Where $ST$ represents the subtask ID.

You must return a vector where the $i$-th element represents the actual episode number of the CD with label $i$.

During the interaction, you may call the following function:

vector<vector<int>> shuffle(vector<vector<int>> boxes)

Parameter description:

  • boxes: A $B \times K$ 2D array representing the current grouping scheme.
  • Return value: A $B \times K$ 2D array representing the actual episode numbers of the CDs in each box (in random order).

Notes:

  1. The number of calls to shuffle cannot exceed $Q$.
  2. Each time shuffle is called, you must provide a valid grouping scheme ($B$ boxes, each containing $K$ CDs, and including all CD labels from $1$ to $N$).

Examples

Initial conditions:

  • $N=6$, $B=3$, $K=2$, $Q=100$
  • Actual episode mapping: $[3,1,4,5,2,6]$ (i.e., label 1 → episode 3, label 2 → episode 1, ...)

Interaction process:

  • Call shuffle([[1,2],[3,4],[5,6]])
    • Might return [[6,2],[5,4],[3,1]]
  • Call shuffle([[2,6],[3,1],[5,4]])
    • Might return [[6,1],[2,5],[4,3]]
  • Call shuffle([[6,5],[4,2],[3,1]])
    • Might return [[5,1],[3,4],[2,6]]

Correct output:

  • Return [3,1,4,5,2,6]

Constraints

For all data:

  • $B,K\geq 2$
  • $N\geq 6$
  • $N=B\times K$

Subtasks

Subtask ID Special Properties Score
$1$ $N=6$, $B=2$, $K=3$, $Q=100$ $2$
$2$ $N=6$, $B=3$, $K=2$, $Q=100$ $3$
$3$ $N \leq 1000$, $Q=12$, box order is guaranteed to be preserved when returning results $15$
$4$ $N \leq 1000$, $K=2$, $Q=4$ $20$
$5$ $N \leq 1000$, $B=2$, $Q=12$ $20$
$6^{*}$ $N \leq 1000$, $Q=2000$, $B,K>2$ $40$

$*$ : Subtask $6$ has partial points. Let $q$ be your maximum number of queries:

  • $q > 2000$: $0$ points
  • $500 < q \leq 2000$: $6$ points
  • $50 < q \leq 500$: $15$ points
  • $9 < q \leq 50$: $15 + 25 \times (\frac{50-q}{41})^2$ points
  • $q \leq 9$: $40$ points

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.