首页 > 试题广场 >

最小长方形

[编程题]最小长方形
  • 热度指数:5120 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
    给定一系列2维平面点的坐标(x, y),其中x和y均为整数,要求用一个最小的长方形框将所有点框在内。长方形框的边分别平行于x和y坐标轴,点落在边上也算是被框在内。

输入描述:
    测试输入包含若干测试用例,每个测试用例由一系列坐标组成,每对坐标占一行,其中|x|和|y|小于1e18;一对0 坐标标志着一个测试用例的结束。注意(0, 0)不作为任何一个测试用例里面的点。一个没有点的测试用例标志着整个输入的结束。


输出描述:
    对每个测试用例,在1行内输出2对整数,其间用一个空格隔开。第1对整数是长方形框左下角的坐标,第2对整数是长方形框右上角的坐标。
示例1

输入

12 56
23 56
13 10
0 0
12 34
0 0
0 0

输出

12 10 23 56
12 34 12 34
头像 牛客409727319号
发表于 2023-02-12 21:27:17
#include <iostream> #include <vector> #include<algorithm> using namespace std; int main() { int a, b; vector<int> xx, 展开全文
头像 牛客440904392号
发表于 2024-09-30 22:04:02
numsX, numsY = [], [] while True: try: x, y = map(int, input().split()) if x == 0 and y == 0: print(min(numsX), min(nu 展开全文
头像 牛客892605956号
发表于 2024-03-26 13:49:32
#include <iostream> #include <set> using namespace std; int main() { int a, b, tt = 0; set<int> v1, v2; while (cin >> a &g 展开全文
头像 尤姆
发表于 2023-03-10 19:30:53
#include<cstdio> int main(){ int x1, y1; while (scanf("%d%d", &x1, &y1) != EOF){ if (x1 == 0 && y1 == 0){ break; } int n1, n2, m1, m2 展开全文
头像 小花Student
发表于 2024-02-03 19:54:51
#include<iostream> #include<algorithm> const int MAX = 1000; int main() { long long int X[MAX], Y[MAX]; long long int x, y; 展开全文
头像 MountainsHao
发表于 2024-03-15 16:28:56
#include <stdio.h> #define MAX 1e18 typedef long long ll; int main() { long long x, y,minx=MAX,miny=MAX,maxx=0,maxy=0; while (scanf("%lld 展开全文
头像 爱吃肉的海豚服了你个老六
发表于 2024-07-26 10:00:49
#include <iostream> #include <algorithm> #include <cstring> #include <string> #include <map> using namespace std; typede 展开全文
头像 牛客142529159号
发表于 2023-03-18 09:43:54
#include <iostream> #include <string> using namespace std; //判断是否a < b; bool cmp(string a, string b) { if(a[0] == '-' && b[0] == ' 展开全文
头像 24复试上机我必乱杀
发表于 2024-02-08 21:56:39
#include <stdio.h> int main(){ int arr[20][2]; while(1){ if(scanf("%d%d",&arr[0][0],&arr[0][1])==EOF) return 0; if(arr[ 展开全文
头像 上岸上岸上岸111
发表于 2023-02-14 20:50:10
#include <iostream> #include <algorithm> using namespace std; struct dot{ long x; long y; }; dot dots[10000*10000]; int main() 展开全文