题意:

有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. idea出现无效的源发行版:11

    idea启动的时候报错: 点击->file->project structure->project

  2. 如何使用 window api 转换字符集?(std::string与std::wstring的相互转换)

    //宽字符转多字节 std::string W2A(const std::wstring& utf8) { int buffSize = WideCharToMultiByte(CP_ACP, ...

  3. 虚拟机VirtualBox与CentOS 7安装

    一.VirtualBox 我们电脑的操作系统一般都是Windows,如果我们要学习Linux,那么可以在我们的电脑上装个虚拟机,然后在这虚拟机上安装Linux.虚拟机可以用VirtualBox 或者 ...

  4. 【PyQt5-Qt Designer】浅谈关闭窗口

    1.关闭全部窗口(主窗口+所有的子窗口) 在逻辑界面中写入 sys.exit(0) 2.关闭子窗口(其他窗口不关闭) self.close()

  5. php 关于时间函数

    1. 设置时区 date_default_timezone_set() 和 putenv() 让时间安全地设置就,输入如下代码: date_default_timezone_set('UTC'); / ...

  6. ASCLL码中的一些小知识

    其次要记住asill值中   65是A      97是a A与a之间相隔32,用int转换后再用char转换回来. char b = s.charAt(i);为字符串转换成一个一个的.

  7. 【Oracle】使用bbed手动提交事务

    有时候数据库挂掉,起库会出现ORA-00704错误,而导致ORA-00704错误的根本原因是訪问OBJ$的时候.ORACLE须要回滚段中的数据,而訪问回滚段的时候须要的undo数据已经被覆盖,此时我们 ...

  8. 误删除innodb ibdata数据文件 文件句柄 文件描述符 proc fd

    误删除innodb ibdata数据文件  文件句柄  文件描述符  proc  fd http://www.cnblogs.com/gomysql/p/3702216.html 提示:如果不小心通过 ...

  9. C# 线程池ThreadPool的用法简析

    https://blog.csdn.net/smooth_tailor/article/details/52460566 什么是线程池?为什么要用线程池?怎么用线程池? 1. 什么是线程池? .NET ...

  10. wx.Panel

    Panel是窗口的容器,通常其大小与Frame一样,在其上放置各种控件,这样可将窗口内容与工具栏及状态栏区分开,能过TAB键可遍历Panel中的元素   小构件,如按钮,文本框等被放置在面板窗口. w ...