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 ...
随机推荐
- SQL SERVER 查看数据库安装时间
--通过name为NT AUTHORITY\SYSTEM的登录账号的create_date,就知道SQL Server的安装日期了. SELECT * FROM SYS.SERVER_PRINCIPA ...
- python第一百一十八天---ajax--图片验证码 + Session
原生AJAX Ajax主要就是使用 [XmlHttpRequest]对象来完成请求的操作,该对象在主流浏览器中均存在(除早起的IE),Ajax首次出现IE5.5中存在(ActiveX控件). 1.Xm ...
- JAVA初识,JAVA是什么?
一.什么是JAVA Java是一门面向对象编程语言,不仅吸收了C++语言的各种优点,还摒弃了C++里难以理解的多继承.指针等概念,因此Java语言具有功能强大和简单易用两个特征. Java语言作为静态 ...
- DVWA v1.9 新手指南
DVWA简介 DVWA(Damn Vulnerable Web Application)是一个用来进行安全脆弱性鉴定的PHP/MySQL Web应用,旨在为安全专业人员测试自己的专业技能和工具提供合法 ...
- 【2018.05.10 智能驾驶/汽车电子】AutoSar Database-ARXML及Vector Database-DBC的对比
最近使用python-canmatrix对can通信矩阵进行编辑转换时,发现arxml可以很容易转换为dbc,而dbc转arxml却需要费一番周折,需要额外处理添加一些信息. 注意:这里存疑,还是需要 ...
- PHP程序员的能力水平层次
PHP程序员的能力水平层次 之前看过很多篇关于服务端工程师和PHP开发者的能力模型介绍,每篇都对能力有侧重点. 下面我们来详细谈谈以开发能力为基准点的PHP程序员的能力水平层次. 层层递进 1.功能开 ...
- 洛谷P1274-魔术数字游戏
Problem 洛谷P1274-魔术数字游戏 Accept: 118 Submit: 243Time Limit: 1000 mSec Memory Limit : 128MB Probl ...
- 经典Python进阶文档 真的很棒
https://docs.pythontab.com/interpy/args_kwargs/README/
- python入门学习:7.函数
python入门学习:7.函数 关键点:函数 7.1 定义函数7.2 传递实参7.3 返回值7.4 传递列表7.5 传递任意数量的实参7.6 将函数存储在模块中 7.1 定义函数 使用关键字def ...
- Python socket套接字简单例子