CF1108A Two distinct points

    • 88通过
    • 126提交
  • 题目来源 CodeForces 1108A
  • 评测方式 RemoteJudge
  • 标签
  • 难度 普及-
  • 时空限制 1000ms / 256MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 体验新版界面

    最新讨论 显示

    推荐的相关题目 显示

    题意翻译

    题目描述

    给定你数轴上的两条线段 $[l_1, r_1],[l_2, r_2]$(可能相交,重叠或重合)。你需要找到两个整数 $a,b$ 满足 $l_1 \leq a \leq r_1, l_2 \leq b \leq r_2$,且 $a\neq b$。你需要回答 $q$ 个询问,可能存在多种答案,输出任意一个即可。

    输入输出格式

    输入格式:

    第一行输入一个整数 $q (1\leq q \leq 500)$,表示询问数量。 接下来 $q$ 行,每行有四个整数 $l_{1_i}, r_{1_i},l_{2_i}, r_{2_i}(1\leq l_{1_i},r_{1_i},l_{2_i},r_{2_i}\leq 10^9,l_{1_i} < r_{1_i},l_{2_i} < r_{2_i})$,表示第 $i$ 个询问的两条线段。

    输出格式:

    输出 $2q$ 个整数,每行两个整数 $a_i,b_i$ 表示第 $i$ 个询问的答案,且满足要求 $l_{1_i} \leq a \leq r_{1_i}, l_{2_i} \leq b \leq r_{2_i},a_i\neq b_i$

    题目描述

    You are given two segments $ [l_1; r_1] $ and $ [l_2; r_2] $ on the $ x $ -axis. It is guaranteed that $ l_1 < r_1 $ and $ l_2 < r_2 $ . Segments may intersect, overlap or even coincide with each other.

    The example of two segments on the $ x $ -axis.Your problem is to find two integers $ a $ and $ b $ such that $ l_1 \le a \le r_1 $ , $ l_2 \le b \le r_2 $ and $ a \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 $ [l_1; r_1] $ and the second one belongs to the segment $ [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 $ q $ independent queries.

    输入输出格式

    输入格式:

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

    Each of the next $ q $ lines contains four integers $ l_{1_i}, r_{1_i}, l_{2_i} $ and $ r_{2_i} $ ( $ 1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} < r_{1_i}, l_{2_i} < r_{2_i} $ ) — the ends of the segments in the $ i $ -th query.

    输出格式:

    Print $ 2q $ integers. For the $ i $ -th query print two integers $ a_i $ and $ b_i $ — such numbers that $ l_{1_i} \le a_i \le r_{1_i} $ , $ l_{2_i} \le b_i \le r_{2_i} $ and $ a_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.

    输入输出样例

    输入样例#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
    
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。