CF1108A.Two distinct points

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two segments [l1;r1][l_1; r_1] and [l2;r2][l_2; r_2] on the xx-axis. It is guaranteed that l1<r1l_1 \lt r_1 and l2<r2l_2 \lt r_2. Segments may intersect, overlap or even coincide with each other.

The example of two segments on the xx-axis.

Your problem is to find two integers aa and bb such that l1≤a≤r1l_1 \le a \le r_1, l2≤b≤r2l_2 \le b \le r_2 and a≠ba \ne b. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment [l1;r1][l_1; r_1] and the second one belongs to the segment [l2;r2][l_2; r_2].

It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.

You have to answer qq independent queries.

给定 xx 轴上的两个线段 [l1;r1][l_1; r_1] 和 [l2;r2][l_2; r_2]。保证 l1<r1l_1 \lt r_1 且 l2<r2l_2 \lt r_2。这两个线段可能相交、重叠,甚至完全重合。

xx 轴上两个线段的示例。

你的任务是找出两个整数 aa 和 bb,满足 l1≤a≤r1l_1 \le a \le r_1,l2≤b≤r2l_2 \le b \le r_2,且 a≠ba \ne b。换言之,你需要选择两个互不相同的整数点,使得第一个点位于线段 [l1;r1][l_1; r_1] 上,第二个点位于线段 [l2;r2][l_2; r_2] 上。

题目保证答案一定存在。若存在多个可行解,输出任意一个即可。

你需要回答 qq 个相互独立的查询。

输入格式

The first line of the input contains one integer qq (1≤q≤5001 \le q \le 500) — the number of queries.

Each of the next qq lines contains four integers l1i,r1i,l2il_{1_i}, r_{1_i}, l_{2_i} and r2ir_{2_i} (1≤l1i,r1i,l2i,r2i≤109,l1i<r1i,l2i<r2i1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} \lt r_{1_i}, l_{2_i} \lt r_{2_i}) — the ends of the segments in the ii-th query.

输入的第一行包含一个整数 qq(1≤q≤5001 \le q \le 500),表示查询次数。

接下来的 qq 行,每行包含四个整数 l1i,r1i,l2il_{1_i}, r_{1_i}, l_{2_i} 和 r2ir_{2_i}(1≤l1i,r1i,l2i,r2i≤1091 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9,且 l1i<r1il_{1_i} \lt r_{1_i},l2i<r2il_{2_i} \lt r_{2_i}),表示第 ii 次查询中两个区间的端点。

输出格式

Print 2q2q integers. For the ii-th query print two integers aia_i and bib_i — such numbers that l1i≤ai≤r1il_{1_i} \le a_i \le r_{1_i}, l2i≤bi≤r2il_{2_i} \le b_i \le r_{2_i} and ai≠bia_i \ne b_i. Queries are numbered in order of the input.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

输出 2q2q 个整数。对于第 ii 个查询,输出两个整数 aia_i 和 bib_i,满足 l1i≤ai≤r1il_{1_i} \le a_i \le r_{1_i}、l2i≤bi≤r2il_{2_i} \le b_i \le r_{2_i},且 ai≠bia_i \ne b_i。查询按输入顺序编号。

保证答案存在。若存在多个答案,输出任意一个即可。

输入输出样例

  • 输入#1

    5
    1 2 1 2
    2 6 3 4
    2 4 1 3
    1 2 1 3
    1 4 5 8

    输出#1

    2 1
    3 4
    3 2
    1 2
    3 7

输入解题思路,AI测评打分。不知道怎么写?

首页