{"problem":{"name":"E. Help Shrek and Donkey","description":{"content":"Shrek and the Donkey (as you can guess, they also live in the far away kingdom) decided to play a card game called YAGame. The rules are very simple: initially Shrek holds _m_ cards and the Donkey hol","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF98E"},"statements":[{"statement_type":"Markdown","content":"Shrek and the Donkey (as you can guess, they also live in the far away kingdom) decided to play a card game called YAGame. The rules are very simple: initially Shrek holds _m_ cards and the Donkey holds _n_ cards (the players do not see each other's cards), and one more card lies on the table face down so that both players cannot see it as well. Thus, at the beginning of the game there are overall _m_ + _n_ + 1 cards. Besides, the players know which cards the pack of cards consists of and their own cards (but they do not know which card lies on the table and which ones the other player has). The players move in turn and Shrek starts. During a move a player can:\n\n*   Try to guess which card is lying on the table. If he guesses correctly, the game ends and he wins. If his guess is wrong, the game also ends but this time the other player wins.\n*   Name any card from the pack. If the other player has such card, he must show it and put it aside (so that this card is no longer used in the game). If the other player doesn't have such card, he says about that.\n\nRecently Donkey started taking some yellow pills and winning over Shrek. Now Shrek wants to evaluate his chances to win if he too starts taking the pills.Help Shrek assuming the pills are good in quality and that both players using them start playing in the optimal manner.\n\n## Input\n\nThe first line contains space-separated integers _m_ and _n_ (0 ≤ _m_, _n_ ≤ 1000).\n\n## Output\n\nPrint space-separated probabilities that Shrek wins and Donkey wins correspondingly; the absolute error should not exceed 10 - 9.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"Shrek 和驴子（正如你所猜的，他们也住在遥远的王国）决定玩一种叫 YAGame 的纸牌游戏。规则非常简单：初始时 Shrek 持有 #cf_span[m] 张牌，驴子持有 #cf_span[n] 张牌（玩家看不到对方的牌），此外有一张牌面朝下放在桌上，两位玩家也都看不到它。因此，游戏开始时总共有 #cf_span[m + n + 1] 张牌。此外，玩家知道整副牌包含哪些牌以及自己手中的牌（但他们不知道桌上是哪张牌，也不知道对方手中有哪些牌）。玩家轮流行动，Shrek 先手。在一轮行动中，一名玩家可以：\n\n假设药丸质量良好，且双方均以最优策略进行游戏，请帮助 Shrek。\n\n第一行包含用空格分隔的整数 #cf_span[m] 和 #cf_span[n]（#cf_span[0 ≤ m, n ≤ 1000]）。\n\n请输出用空格分隔的 Shrek 获胜和驴子获胜的概率；绝对误差不应超过 #cf_span[10 - 9]。\n\n## Input\n\n第一行包含用空格分隔的整数 #cf_span[m] 和 #cf_span[n]（#cf_span[0 ≤ m, n ≤ 1000]）。\n\n## Output\n\n请输出用空格分隔的 Shrek 获胜和驴子获胜的概率；绝对误差不应超过 #cf_span[10 - 9]。\n\n[samples]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ m, n \\in \\mathbb{Z}_{\\geq 0} $ denote the number of cards held by Shrek and Donkey, respectively.  \nLet $ N = m + n + 1 $ be the total number of distinct cards in the deck.  \nLet $ C $ be the set of all $ N $ distinct cards.  \nShrek knows his $ m $ cards, Donkey knows his $ n $ cards, and the remaining card $ c^* \\in C \\setminus (\\text{Shrek's cards} \\cup \\text{Donkey's cards}) $ is face down on the table.  \n\n**Constraints**  \n1. $ 0 \\leq m, n \\leq 1000 $  \n2. $ m + n \\leq N - 1 $, and $ N \\leq 2001 $  \n\n**Objective**  \nCompute the probabilities $ P_S $ and $ P_D $ that Shrek and Donkey win, respectively, under optimal play, where:  \n- Players alternate turns, Shrek starts.  \n- On a turn, a player must play a card from their hand that is either greater than or less than the top card on the table (initially unknown).  \n- If a player cannot play a valid card, they lose.  \n- The face-down card $ c^* $ is uniformly random among the $ N - m - n $ unknown cards.  \n\nLet $ \\mathcal{U} = C \\setminus (\\text{Shrek's cards} \\cup \\text{Donkey's cards}) $, $ |\\mathcal{U}| = N - m - n $.  \nFor each $ c^* \\in \\mathcal{U} $, define the game state $ G(c^*) $ as the deterministic game with known card distributions.  \nLet $ W_S(c^*) = 1 $ if Shrek wins under optimal play with table card $ c^* $, else $ 0 $.  \nThen:  \n$$\nP_S = \\frac{1}{|\\mathcal{U}|} \\sum_{c^* \\in \\mathcal{U}} W_S(c^*), \\quad P_D = 1 - P_S\n$$","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF98E","tags":["dp","games","math","probabilities"],"sample_group":[["0 3","0.25 0.75"],["1 0","1 0"],["1 1","0.5 0.5"]],"created_at":"2026-03-03 11:00:39"}}