题意:

有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. activeMQ配置文件

    <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agree ...

  2. SQL函数汇总大全

    聚合函数对一组值计算后返回单个值.除了count(统计项数)函数以外,其他的聚合函数在计算式都会忽略空值(null).所有的聚合函数均为确定性函数.即任何时候使用一组相同的输入值调用聚合函数执行后的返 ...

  3. 【PyQt5-Qt Designer】猜数字(小项目)

    参考:https://zhuanlan.zhihu.com/p/28287825 https://www.cnblogs.com/hhh5460/p/5174266.html 最终效果: 本次练习涉及 ...

  4. word2vec训练好的词向量

    虽然早就对NLP有一丢丢接触,但是最近真正对中文文本进行处理才深深感觉到自然语言处理的难度,主要是机器与人还是有很大差异的,毕竟人和人之间都是有差异的,要不然不会讲最难研究的人嘞 ~~~~~~~~~~ ...

  5. 求助!使用 ReportViewer 控件集成 Reporting Services2008 时,报"...401 unauthorized"错误!

    实现接口 public class ReportServiceCredetials : Microsoft.Reporting.WebForms.IReportServerCredentials { ...

  6. 同步fifo的Verilog实现

    FIFO是一种先进先出的数据缓存器,他与普通存储器相比: 优点:没有外部读写地址线,这样使用起来非常简单: 缺点:只能顺序写入数据,顺序的读出数据, 其数据地址由内部读写指针自动加1完成,不能像普通存 ...

  7. thinkphp模板使用

    1.模板文件 就是个html,可以保存到View的Public文件夹下,比如叫base.html(参考onethink) <block name="a">a</b ...

  8. Java的transient关键字(转)

    Volatile修饰的成员变量在每次被线程访问时,都强迫从主内存中重读该成员变量的值.而且,当成员变量发生变化时,强迫线程将变化值回写到主内存.这样在任何时刻,两个不同的线程总是看到某个成员变量的同一 ...

  9. vue 手指长按触发事件

    按钮 <span class="btn" @touchstart="gtouchstart()" @touchmove="gtouchmove( ...

  10. JsonResponse返回中文乱码问题

    class Publish(APIView): def get(self, request): publish_list = models.Publish.objects.all() bs = MyS ...