AtCoder Regular Contest 092 C - 2D Plane 2N Points(二分图匹配)
Problem Statement
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (ai,bi), and the coordinates of the i-th blue point are (ci,di).
A red point and a blue point can form a friendly pair when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.
At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
Constraints
- All input values are integers.
- 1≤N≤100
- 0≤ai,bi,ci,di<2N
- a1,a2,…,aN,c1,c2,…,cN are all different.
- b1,b2,…,bN,d1,d2,…,dN are all different.
Input
Input is given from Standard Input in the following format:
N
a1 b1
a2 b2
:
aN bN
c1 d1
c2 d2
:
cN dN
Output
Print the maximum number of friendly pairs.
Sample Input 1
3
2 0
3 1
1 3
4 2
0 4
5 5
Sample Output 1
2
For example, you can pair (2,0) and (4,2), then (3,1) and (5,5).
Sample Input 2
3
0 0
1 1
5 2
2 3
3 4
4 5
Sample Output 2
2
For example, you can pair (0,0) and (2,3), then (1,1) and (3,4).
Sample Input 3
2
2 2
3 3
0 0
1 1
Sample Output 3
0
It is possible that no pair can be formed.
Sample Input 4
5
0 0
7 3
2 2
4 8
1 6
8 5
6 9
5 4
9 1
3 7
Sample Output 4
5
Sample Input 5
5
0 0
1 1
5 5
6 6
7 7
2 2
3 3
4 4
8 8
9 9
Sample Output 5
4
#include<bits/stdc++.h>
using namespace std; const int N=;
pair<int,int> p[N];
int vis[N],match[N];
int n;
int Find(int u)
{
for(int i=n+;i<=n+n;i++)
{
if(p[i].first>p[u].first&&p[i].second>p[u].second&&!vis[i])
{
vis[i]=;
if(!match[i]||Find(match[i]))
{
match[i]=u;
return ;
}
}
}
return ;
}
int main()
{
cin>>n;
for(int i=;i<=n+n;i++)
cin>>p[i].first>>p[i].second;
int ans=;
for(int i=;i<=n;i++)
{
memset(vis,,sizeof(vis));
if(Find(i))
ans++;
}
cout<<ans;
return ;
}
AtCoder Regular Contest 092 C - 2D Plane 2N Points(二分图匹配)的更多相关文章
- AtCoder Regular Contest 092
AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...
- 【AtCoder Regular Contest 092】C.2D Plane 2N Points【匈牙利算法】
C.2D Plane 2N Points 题意:给定N个红点二维坐标N个蓝点二维坐标,如果红点横纵坐标都比蓝点小,那么它们能够构成一组.问最多能构成多少组. 题解:把满足要求的红蓝点连线,然后就是匈牙 ...
- AtCoder Regular Contest 092 C D E F
C - 2D Plane 2N Points 题意 二维平面上有\(N\)个红点,\(N\)个蓝点,一个红点和一个蓝点能配成一对当且仅当\(x_r<x_b\)且\(y_r<y_b\). 问 ...
- AtCoder Regular Contest 092 2D Plane 2N Points AtCoder - 3942 (匈牙利算法)
Problem Statement On a two-dimensional plane, there are N red points and N blue points. The coordina ...
- Atcoder Regular Contest 092 D - Two Faced Edges(图论+bitset 优化)
Atcoder 题面传送门 & 洛谷题面传送门 orz ymx,ymx ddw %%% 首先既然题目要我们判断强连通分量个数是否改变,我们首先就将原图 SCC 缩个点呗,缩完点后我们很自然地将 ...
- Atcoder Regular Contest 092 A 的改编
原题地址 题目大意 给定平面上的 $n$ 个点 $p_1, \dots, p_n$ .第 $i$ 点的坐标为 $(x_i, y_i)$ .$x_i$ 各不相同,$y_i$ 也各不相同.若两点 $p_i ...
- AtCoder Regular Contest 092 B Two Sequences
题目大意 给定两个长为 $n$ 个整数序列 $a_1, \dots, a_n$ 和 $b_1, \dots, b_n$ .求所有 $a_i + b_j$($1\le i, j\le n$)的 XOR ...
- 思维定势--AtCoder Regular Contest 092 D - Two Sequences
$n \leq 100000$的俩序列,数字范围$2^{28}$,问所有$a_i+b_j$的$n^2$个数字的异或和. 这种东西肯定是按位考虑嘛,从低位开始然后补上进位.比如说第一位俩串分别有$c$个 ...
- AtCoder Regular Contest 092 Two Sequences AtCoder - 3943 (二进制+二分)
Problem Statement You are given two integer sequences, each of length N: a1,…,aN and b1,…,bN. There ...
随机推荐
- Git 上传文件到 码云 gitee
1:git bash 执行如下 git config –global user.name “eason” git config –global user.email “your email@qq.co ...
- APP-11-视觉技术-通用文字识别
1.Postman测试 2.参数 https://cloud.baidu.com/doc/OCR/OCR-API.html#.EC.DF.48.27.9B.69.A4.2C.54.1B.DC.95.6 ...
- Linux:使用读写锁使线程同步
基础与控制原语 读写锁 与互斥量类似,但读写锁允许更高的并行性.其特性为:写独占,读共享. 读写锁状态: 一把读写锁具备三种状态: 1. 读模式下加锁状态 (读锁) 2. 写模式下加锁 ...
- 1.ossutil初步使用
ossutil对应的阿里云参考文档链接地址: https://help.aliyun.com/document_detail/50452.html?spm=a2c4g.11186623.6.1355. ...
- nginx+php 开启https
nginx 配置如下,配置好重启nginx,不是nginx -s reload,如果还不能访问肯定就是防火墙问题,关闭防火墙再试试. 我遇到的问题是:我服务器是ecs,域名解析到阿里云复杂均衡的,结果 ...
- FlashDevelop 发布SWC
环境配置: 1.安装32位Java,经测试可用的 链接:http://pan.baidu.com/s/1i4CraXR 密码:xuud 2.ant,链接:http://pan.baidu.com/s/ ...
- WebStorm新创建项目介绍
WebStorm创建一个项目 这里支持有很多的类型项目: Empty Project ----一个空的项目 Html5 Boilerplate ----HTML5开发框架 We ...
- react native 中es6语法解析
react native是直接使用es6来编写代码,许多新语法能提高我们的工作效率 解构赋值 var { StyleSheet, Text, View } = React; 这句代码是ES6 中新增的 ...
- 自行编译mwan加入openwrt里
参考源文:http://www.right.com.cn/forum/thread-124449-1-1.html 本例以 opoenwrt 12.09正式版为例,原软件来自openwrt 英文论坛: ...
- c# vs2013部署项目
http://demo.netfoucs.com/shinepan/article/details/24865931