Codeforces Round 986 (Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2028 Codeforces Round 986 (Div. 2) FINISHED False 7200 45152723 Nov. 10, 2024, 3:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 3724 ) D Alice's Adventures in Cards PROGRAMMING constructive algorithms data structures dfs and similar dp graphs greedy implementation shortest paths

Alice is playing cards with the Queen of Hearts, King of Hearts, and Jack of Hearts. There are (n) different types of cards in their card game. Alice currently has a card of type (1) and needs a card of type (n) to escape Wonderland. The other players have one of each kind of card. In this card game, Alice can trade cards with the three other players. Each player has different preferences for the (n) types of cards, which can be described by permutations(^{\text{∗}}) (q), (k), and (j) for the Queen, King, and Jack, respectively. A player values card (a) more than card (b) if for their permutation (p), (p_a > p_b). Then, this player is willing to trade card (b) to Alice in exchange for card (a). Alice's preferences are straightforward: she values card (a) more than card (b) if (a > b), and she will also only trade according to these preferences. Determine if Alice can trade up from card (1) to card (n) subject to these preferences, and if it is possible, give a possible set of trades to do it. (^{\text{∗}})A permutation of length (n) is an array consisting of (n) distinct integers from (1) to (n) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((n=3) but there is (4) in the array). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains an integer (n) ((2\le n\le 2\cdot 10^5)) — the number of card types. The next three lines contain the preferences of the Queen, King, and Jack respectively. Each of these lines contains (n) integers (p_1, p_2, \ldots, p_n) ((1\le p_i\le n)) — a permutation corresponding to the player's preferences. The sum of $$$n$

Tutorials

Codeforces Round 986 (Div. 2) Editorial

Submissions

No solutions yet.