Two distinct points CodeForces - 1108A (签到)
You are given two segments [l1;r1][l1;r1] and [l2;r2][l2;r2] on the xx-axis. It is guaranteed that l1<r1l1<r1 and l2<r2l2<r2. 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≤r1l1≤a≤r1, l2≤b≤r2l2≤b≤r2 and a≠ba≠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][l1;r1] and the second one belongs to the segment [l2;r2][l2;r2].
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.
Input
The first line of the input contains one integer qq (1≤q≤5001≤q≤500) — the number of queries.
Each of the next qq lines contains four integers l1i,r1i,l2il1i,r1i,l2i and r2ir2i (1≤l1i,r1i,l2i,r2i≤109,l1i<r1i,l2i<r2i1≤l1i,r1i,l2i,r2i≤109,l1i<r1i,l2i<r2i) — the ends of the segments in the ii-th query.
Output
Print 2q2q integers. For the ii-th query print two integers aiai and bibi — such numbers that l1i≤ai≤r1il1i≤ai≤r1i, l2i≤bi≤r2il2i≤bi≤r2i and ai≠biai≠bi. Queries are numbered in order of the input.
It is guaranteed that the answer exists. If there are multiple answers, you can print any.
Example
5
1 2 1 2
2 6 3 4
2 4 1 3
1 2 1 3
1 4 5 8
2 1
3 4
3 2
1 2
3 7 思路:给你两个区间,分别表示为[l1,r1] , [l2,r2]
让你输出两个不同的整数a和b,使之a属于第一个区间,b属于第二个区间。保证答案存在,注意a!=b
很签到的一题,注意下细节就好了。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=;while(b){if(b%)ans=ans*a%MOD;a=a*a%MOD;b/=;}return ans;}
inline void getInt(int* p);
const int maxn=;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n; int main()
{
int l1,l2,r1,r2;
gg(n);
while(n--)
{
scanf("%d %d %d %d",&l1,&r1,&l2,&r2);
if(l1!=r2)
printf("%d %d\n",l1,r2 );
else
printf("%d %d\n",r1,l2 );
}
return ;
} inline void getInt(int* p) {
char ch;
do {
ch = getchar();
} while (ch == ' ' || ch == '\n');
if (ch == '-') {
*p = -(getchar() - '');
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * - ch + '';
}
}
else {
*p = ch - '';
while ((ch = getchar()) >= '' && ch <= '') {
*p = *p * + ch - '';
}
}
}
Two distinct points CodeForces - 1108A (签到)的更多相关文章
- Five Dimensional Points CodeForces - 851C (计算几何+暴力)
C. Five Dimensional Points time limit per test 2 seconds memory limit per test 256 megabytes input ...
- Codeforce-A-Two distinct points(暴力)
output standard output You are given two segments [l1;r1][l1;r1] and [l2;r2][l2;r2] on the xx-axis. ...
- B. Cover Points Codeforces Round #511 (Div. 2)【数学】
题目: There are nn points on the plane, (x1,y1),(x2,y2),…,(xn,yn)(x1,y1),(x2,y2),…,(xn,yn). You need t ...
- CF1108A Two distinct points 题解
Content 有 \(q\) 次询问,每次询问给定四个数 \(l_1,r_1,l_2,r_2\).对于每次询问,找到两个数 \(a,b\),使得 \(l_1\leqslant a\leqslant ...
- Codeforces Round #486 (Div. 3) D. Points and Powers of Two
Codeforces Round #486 (Div. 3) D. Points and Powers of Two 题目连接: http://codeforces.com/group/T0ITBvo ...
- codeforces 872E. Points, Lines and Ready-made Titles
http://codeforces.com/contest/872/problem/E E. Points, Lines and Ready-made Titles time limit per te ...
- Codeforces Round #245 (Div. 2) A. Points and Segments (easy) 贪心
A. Points and Segments (easy) Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...
- codeforces 251A Points on Line(二分or单调队列)
Description Little Petya likes points a lot. Recently his mom has presented him n points lying on th ...
- Day8 - A - Points on Line CodeForces - 251A
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. N ...
随机推荐
- 下载安装Emacs和基本配置--待更新中
Emacs下载地址 下载好后,解压到D:\Emacs,并设置环境变量D:\Emacs\bin 熟悉基本操作 光标的移动 文件的创建与打开
- Python输出和输入
一.input()函数 在 Python 中,使用内置函数 input()可以接收用户的键盘输入. input()函数的基本用法如 下: variable = input("提示文字") 其中,var ...
- c/c++ 线性表之顺序表
线性表之顺序表 存储在连续的内存空间,和数组一样. 下面的代码,最开始定义了一个能存8个元素的顺序表,当超过8个元素的时候,会再追加开辟空间(函数:reInit). 实现了以下功能: 函数 功能描述 ...
- Windows Server 2016-Windows Server Backup功能
一.Windows Server Backup 介绍: Windows Server Backup 是一种功能,它提供了一组向导和其他工具,大概从WinSer2008开始Win Ser Backup引 ...
- shell read变量的读入
shell变量的输入: shell变量除了可以直接赋值或脚本传参外,还可以使用read命令从标准输入获取,read为bash内置命令,可以通过help read查看帮助. 语法格式: read [参数 ...
- C++实现第三方资源释放与载入过程(以DLL为例)
简介 我们经常看见有一些程序开始执行时会释放一些文件,以便于后续操作.例如一些病毒为了便于传播和隐藏,经常把一些需要用的动态库或是驱动文件打包进一个可执行文件中,再由需要使用的时候,再临时释放和加载. ...
- win10显示许可证即将过期,但在激活界面显示的仍是已激活问题解决
win10开机显示"许可证即将过期"怎么办? 很多win10用户在开机的时候遇见了"许可证即将过期"请转到设置种激活windows的问题,但是查询自己的win1 ...
- 【算法】LeetCode算法题-Maximum Subarray
这是悦乐书的第154次更新,第156篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第13题(顺位题号是53).给定一个整数数组nums,找出一个最大和,此和是由数组中索引 ...
- 用sed实现wc -w的功能
版权申明:本文为博主窗户(Colin Cai)原创,欢迎转帖.如要转贴,必须注明原文网址 http://www.cnblogs.com/Colin-Cai/p/7663831.html 作者:窗户 Q ...
- JS DOM 实现删除和添加的功能
<!DOCTYPE html> <html> <head> <title>发表评论</title> <link rel="s ...