【AtCoder ABC 075 D】Axis-Parallel Rectangle
【链接】 我是链接,点我呀:)
【题意】
让你找到一个各边和坐标轴平行的矩形。使得这个矩形包含至少K个点。
且这个矩形的面积最小。
【题解】
把所有的“关键点“”都找出来。
然后枚举任意两个点作为矩形的对角。
然后看他是不是包含了至少K个点即可。
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 50;
int n, k;
long long ans = -1;
int xx[N + 10], yy[N + 10];
pair <int, int> a[N*N + 10];
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++)
scanf("%d%d", &xx[i], &yy[i]);
int nn = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[++nn] = make_pair(xx[i], yy[j]);
for (int i = 1; i <= nn; i++)
{
for (int j = i+1; j <= nn; j++)
{
int x1 = min(a[i].first, a[j].first);
int x2 = max(a[i].first, a[j].first);
int y1 = min(a[i].second, a[j].second);
int y2 = max(a[i].second, a[j].second);
int num = 0;
for (int kk = 1; kk <= n; kk++)
if (x1 <= xx[kk] && xx[kk] <= x2 && y1 <= yy[kk] && yy[kk] <= y2)
num++;
if (num >= k)
{
long long s = 1LL * (x2 - x1)*(y2 - y1);
if (ans == -1)
ans = s;
else
ans = min(ans, s);
}
}
}
printf("%lld\n", ans);
return 0;
}
【AtCoder ABC 075 D】Axis-Parallel Rectangle的更多相关文章
- 【AtCoder ABC 075 C】Bridge
[链接] 我是链接,点我呀:) [题意] 让你求出桥的个数 [题解] 删掉这条边,然后看看1能不能到达其他所有的点就可以了 [代码] #include <bits/stdc++.h> us ...
- 【AtCoder ABC 075 B】Minesweeper
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟,把#换成1 八个方向加一下就好. [代码] #include <bits/stdc++.h> using name ...
- 【AtCoder ABC 075 A】One out of Three
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map轻松搞定 [代码] #include <bits/stdc++.h> using namespace std; ...
- 【AtCoder Regular Contest 082】Derangement
[链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错 ...
- 【Atcoder hbpc C 183】1=0.999...
Atcoder hbpc C 题意:给n个循环小数或者有限小数,问其中有多少个互不相同的. 思路:我的思路比较繁琐. 首先我们考虑分数化小数:假设原来的数是\(a.b(c)\),那么这个分数就是\(a ...
- 【AtCoder Regular Contest 080E】Young Maids [堆][线段树]
Young Maids Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一个排列,每次选出相邻的两个放在队头,要求字典序最小. Input ...
- 【AtCoder Grand Contest 007E】Shik and Travel [Dfs][二分答案]
Shik and Travel Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一棵n个点的树,保证一个点出度为2/0. 遍历一遍,要求每 ...
- 【AtCoder Grand Contest 001F】Wide Swap [线段树][拓扑]
Wide Swap Time Limit: 50 Sec Memory Limit: 512 MB Description Input Output Sample Input 8 3 4 5 7 8 ...
- 【AtCoder Grand Contest 012C】Tautonym Puzzle [构造]
Tautonym Puzzle Time Limit: 50 Sec Memory Limit: 256 MB Description 定义一个序列贡献为1,当且仅当这个序列 由两个相同的串拼接而成 ...
随机推荐
- ASP.Net简单的交互案例
控制器 using System; using System.Collections.Generic; using System.Linq; using System.Web; using Syste ...
- javafx tabPane
public class EffectTest extends Application { @Override public void start(Stage primaryStage) { prim ...
- noi2019模拟测试赛(四十七)
noi2019模拟测试赛(四十七) T1与运算(and) 题意: 给你一个序列\(a_i\),定义\(f_i=a_1\&a_2\&\cdots\&a_i\),求这个序列的所 ...
- 小的时候.by小雷
小的时候,总是有很多想法. 想去做,却做不成. 因为,自己小,被父母约束着,被学校圈着,被老师教育着. 想买个小霸王游戏机,没钱.在父辈的眼中,"游戏" ,游戏室,电脑游戏 ...
- Struts2+Spring+Hibernate step by step 06 整合Hibernate
注:该系列教程.部分内容来自王健老师编写ssh整合开发教程 Hibernate是一款优秀的ORM(Object Relation Mapping-对象关系映射图)工具.与Struts.Spring项目 ...
- actionBar-shareIcon 分享按钮的修改
今天为了修改图库的分享按钮,进行了很多的尝试 1.寻找到了xml文件,如下 <?xml version="1.0" encoding="utf-8"?&g ...
- thinkphp最简单路由
thinkphp最简单路由 一.总结 1.路由应用场景(前台要,后台不要):前台所有人都可以看,所以前台的话设置路由,后台的话并不是所有人都进去,所以不需要设置路由 2.模块分离来实现路由场景应用:前 ...
- 使用SqlBulkCopy进行批量数据插入
Dim dt As DataTable = New DataTable() dt.Columns.Add("DtCostProductRuleGUID", GetType(Guid ...
- Flume的data flow(数据流)
data flow描述了数据从产生,传输.处理并最终写入目标的一条路径. 数据的采集的流向!如下图所示.
- golang excel
github.com/tealeg/xlsx 封装的接口简单易用 package main import ( "bufio" "fmt" "githu ...