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

题意: 有n个红色的点和n个蓝色的点,如果红色的点的横坐标和纵坐标分别比蓝色的点的横坐标和纵坐标小,那么这两个点就可以成为一对友好的点. 问最多可以形成多少对友好的点. 思路: 裸的二分图匹配,对于满足条件的两个点连边. wa了两发,板子错了,还是得用果苣的!. 代码: #include <stdio.h> #include <string.h> ; int link[N]; bool mp[N][N]; bool vis[N]; struct node { int x,y; }…
C.2D Plane 2N Points 题意:给定N个红点二维坐标N个蓝点二维坐标,如果红点横纵坐标都比蓝点小,那么它们能够构成一组.问最多能构成多少组. 题解:把满足要求的红蓝点连线,然后就是匈牙利算法(详情见这里,写的好棒!) #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; ; int a[maxn],b[max…
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 w…
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 w…
题目链接:https://abc091.contest.atcoder.jp/tasks/arc092_a 题意 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…
Find the K closest points to the origin in a 2D plane, given an array containing N points. 用 max heap 做 /* public class Point { public int x; public int y; public Point(int x, int y) { this.x = x; this.y = y; } } */ public List<Point> findKClosest(P…
//定义二维平面上的点struct Point { int x; int y; Point(, ):x(a),y(b){} }; bool operator==(const Point& left, const Point& right) { return (left.x==right.x && left.y==right.y); } //求两个点连接成的直线所对应的斜率 double line_equation(const Point& P1, const Poi…
C - 2D Plane 2N Points 把能连边的点找到然后跑二分图匹配即可 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define space putchar(' ') #define enter putchar('\n') #define mp make_pair #define MAXN 100005 //#define ivorysi u…
AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\)类点.每个\(A\)类点可以和横纵坐标都比它大的\(B\)类点匹配,求最大匹配数. 分析: 网络流裸题. #include <bits/stdc++.h> using namespace std; #define MAXN 110 #define inf 0x7fffffff int head[5…
C - 2D Plane 2N Points 题意 二维平面上有\(N\)个红点,\(N\)个蓝点,一个红点和一个蓝点能配成一对当且仅当\(x_r<x_b\)且\(y_r<y_b\). 问最多能形成多少pair. 思路 无脑版本:可以匹配的连边,然后跑匈牙利. 正确的贪心姿势:对于所有的点按\(x\)从小到大排序,对于蓝点,要匹配的最优的红点即为 在其之前出现的 \(y\)小于它的 且\(y\)最大的 红点.用一个\(set\)维护红点的\(y\)坐标即可. Code #include <…