Codeforces Round 1091 (Div. 2) and CodeCraft 26
F
Interval Game
Codeforces
2400
原题
← EG →
翻译中…

Alice and Bob are playing a game involving two intervals, $[l_1, r_1]$ and $[l_2, r_2]$, constrained by integers $x_1$ and $x_2$ respectively. The intervals satisfy $1 \le l_1 \le r_1 \le x_1$ and $1 \le l_2 \le r_2 \le x_2$.

翻译中…

The game is played as follows. In one turn, a player must choose one of the two intervals (let's say the $i$-th interval $[l_i, r_i]$) and perform exactly one of the following operations:

翻译中…
  • Replace $l_i$ with a strictly smaller integer $l'_i$ such that $1 \le l'_i \lt l_i$.
  • Replace $r_i$ with a strictly larger integer $r'_i$ such that $r_i \lt r'_i \le x_i$.
翻译中…

The player who cannot make a valid move loses the game.

翻译中…

The game setup proceeds in two steps:

翻译中…
  1. First, Alice chooses the values of $l_1$ and $r_1$ to determine the first interval. It must be a valid interval within $[1, x_1]$.
  2. Then, the second interval $[l_2, r_2]$ is chosen uniformly at random from all possible valid intervals within $[1, x_2]$.
翻译中…

Once the intervals are chosen, the game begins with Alice moving first.

翻译中…

Assuming both Alice and Bob play optimally, Alice wants to choose the initial interval $[l_1, r_1]$ to maximize her probability of winning. Your task is to find such an interval. If there are multiple optimal intervals, you may output any one of them.

翻译中…

Input

翻译中…

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 only line of each test case contains two integers $x_1$ and $x_2$ ($1 \le x_1, x_2 \le 5 \cdot 10^5$) — the upper bounds for the two intervals.

翻译中…

It is guaranteed that the sum of $x_1$ over all test cases does not exceed $5 \cdot 10^5$.

翻译中…

It is guaranteed that the sum of $x_2$ over all test cases does not exceed $5 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output two integers $l_1$ and $r_1$ ($1 \le l_1 \le r_1 \le x_1$) — the optimal interval chosen by Alice.

翻译中…

If there are multiple optimal intervals, you may output any one of them.

翻译中…

Note

翻译中…

For the first test case, Alice is forced to choose $[1, 1]$ as it is the only valid option.

翻译中…

For the third test case, if Alice chooses $[2, 2]$, she is guaranteed to win (probability $1$); she can replace $l_1$ with $1$, after which Bob cannot make a valid move. Note that $[1, 1]$ would also be a valid winning answer here.

翻译中…

For the fourth test case, if Alice chooses $[1, 2]$, she achieves a winning probability of $2/3$. By contrast, choosing $[1, 1]$ or $[2, 2]$ would result in a winning probability of only $1/3$.

翻译中…

样例

Input #1
6
1 1
1 10
2 1
2 2
20 64578
185367 133524
Output #1
1 1
1 1
2 2
1 2
5 12
37381 52023
InputCopy OutputCopy
题目信息
题号
2217F
时间限制
3 s
内存限制
256 MB
标签
位运算
组合数学
构造
动态规划
博弈论
贪心
数学
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。