题意:

有n个红色的点和n个蓝色的点,如果红色的点的横坐标和纵坐标分别比蓝色的点的横坐标和纵坐标小,那么这两个点就可以成为一对友好的点。

问最多可以形成多少对友好的点。

思路:

裸的二分图匹配,对于满足条件的两个点连边。

wa了两发,板子错了,还是得用果苣的!。

代码:

 #include <stdio.h>
#include <string.h> const int N = ; int link[N];
bool mp[N][N];
bool vis[N]; struct node
{
int x,y;
} red[N],blue[N]; bool dfs(int u,int n)
{
for (int i = ;i < n;i++)
{
if (mp[u][i] && !vis[i])
{
vis[i] = ; if (link[i] == - || dfs(link[i],n))
{
link[i] = u;
return true;
}
}
} return false;
} int solve(int n)
{
int ans = ; for (int i = ;i < n;i++)
{
memset(vis,,sizeof(vis));
if (dfs(i,n)) ans++;
} return ans;
} int main()
{
int n; scanf("%d",&n); memset(link,-,sizeof(link)); for (int i = ;i < n;i++)
{
scanf("%d%d",&red[i].x,&red[i].y);
} for (int i = ;i < n;i++)
{
scanf("%d%d",&blue[i].x,&blue[i].y);
} for (int i = ;i < n;i++)
{
for (int j = ;j < n;j++)
{
if (red[i].x < blue[j].x && red[i].y < blue[j].y)
{
mp[i][j] = ;
}
}
} int ans = solve(n); printf("%d\n",ans); return ;
}

arc 092C 2D Plane 2N Points的更多相关文章

  1. 【AtCoder Regular Contest 092】C.2D Plane 2N Points【匈牙利算法】

    C.2D Plane 2N Points 题意:给定N个红点二维坐标N个蓝点二维坐标,如果红点横纵坐标都比蓝点小,那么它们能够构成一组.问最多能构成多少组. 题解:把满足要求的红蓝点连线,然后就是匈牙 ...

  2. 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 coordina ...

  3. 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 ...

  4. AtCoderBeginner091-C 2D Plane 2N Points 模拟问题

    题目链接:https://abc091.contest.atcoder.jp/tasks/arc092_a 题意 On a two-dimensional plane, there are N red ...

  5. Microsoft - Find the K closest points to the origin in a 2D plane

    Find the K closest points to the origin in a 2D plane, given an array containing N points. 用 max hea ...

  6. [LeetCode OJ] Max Points on a Line—Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

    //定义二维平面上的点struct Point { int x; int y; Point(, ):x(a),y(b){} }; bool operator==(const Point& le ...

  7. 【AtCoder】ARC092

    C - 2D Plane 2N Points 把能连边的点找到然后跑二分图匹配即可 #include <bits/stdc++.h> #define fi first #define se ...

  8. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

  9. AtCoder Regular Contest 092 C D E F

    C - 2D Plane 2N Points 题意 二维平面上有\(N\)个红点,\(N\)个蓝点,一个红点和一个蓝点能配成一对当且仅当\(x_r<x_b\)且\(y_r<y_b\). 问 ...

随机推荐

  1. redis使用rdb恢复数据

    redis中存在rdb备份和aof备份两种方式. 如果在redis多个节点发生雪崩时,我们往往使用定期冷备rdb或者aof文件,去恢复数据的方式,但往往数据量较大时rdb恢复更加的快速,毕竟aof保存 ...

  2. python 去除微软的BOM

    傻逼微软会给文件前面加上efbbbf, 导致开发人员浪费很多时间在排错上,下面通过python代码来实现去除微软BOM的功能 用法很简单,指定可能含有BOM开头的文件,并且将微软的\r\n 换成lin ...

  3. u-boot 编译,启动流程分析,移植

    分析u-boot-1.1.6 的启动流程 移植u-boot 2012.04版本到JZ2440开发板 源码百度云链接:https://pan.baidu.com/s/10VnxfDWBqJVGY3SCY ...

  4. atom 为什么启动terminal是总是打开是用户目录?

    atom 为什么启动terminal是总是打开是用户目录?如下图: 原因也很简单,只怪自己懒,没查单词surpress是什么意思: surpress directory argument,是抑制目录参 ...

  5. HttpClient 链接管理

    SOCK is a TCP/IP level proxy protocol, not HTTP. It is not supported by HttpClient out of the box. O ...

  6. pip的问题小结

    Q:同时安装py2和py3后,pip2不能用 A:使用:python2 -m pip install xxx  代替 pip2 install xxx 命令 Q:怎么用pip更新第三方包 A:pip2 ...

  7. (1.9)SQL优化——mysql导入导出优化

    (1.9)SQL优化——mysql导入导出优化 1.大批量插入数据 [1.1]MyISAM: (1)如果存在表且有数据,插入前先关闭所有非唯一索引. (2)如果表是空的,默认就是先导入数据再创建索引, ...

  8. 数据库——MongoDB

    what's the MongoDB MongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的.他支持的数据结构非常松散,是类似json的bson格式 ...

  9. MySQL中的数据类型以及完整性约束

    数据类型 数据库mysql中也是分很多数据类型的,最常用的就是:数字类型.字符类型.日期类型.枚举与集合类型 一.数字类型: 默认都是有符号的,即正负号,若想无符号,在创建表时加unsigned.指定 ...

  10. vue中使用promise

    init1(){ return new Promise((resolve, reject) => { let data={ dateStr:this.time }; api.get('url', ...