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…
C.2D Plane 2N Points 题意:给定N个红点二维坐标N个蓝点二维坐标,如果红点横纵坐标都比蓝点小,那么它们能够构成一组.问最多能构成多少组. 题解:把满足要求的红蓝点连线,然后就是匈牙利算法(详情见这里,写的好棒!) #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> using namespace std; ; int a[maxn],b[max…
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 <…
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…
Atcoder 题面传送门 & 洛谷题面传送门 orz ymx,ymx ddw %%% 首先既然题目要我们判断强连通分量个数是否改变,我们首先就将原图 SCC 缩个点呗,缩完点后我们很自然地将图中的边分为两类:在某个强连通分量中,和不在强连通分量中,我们对这两个情况分别进行讨论. 下面又到了喜闻乐见的找性质的时间了.首先,对于不在同一个强连通分量中的边,把它翻转之后不会影响强连通分量个数,因为这条边不在强连通分量里面,即便把它断掉也不影响强连通分量内部的点的可达性,因此把它翻转只可能接链成环,减…
题意: 有n个红色的点和n个蓝色的点,如果红色的点的横坐标和纵坐标分别比蓝色的点的横坐标和纵坐标小,那么这两个点就可以成为一对友好的点. 问最多可以形成多少对友好的点. 思路: 裸的二分图匹配,对于满足条件的两个点连边. wa了两发,板子错了,还是得用果苣的!. 代码: #include <stdio.h> #include <string.h> ; int link[N]; bool mp[N][N]; bool vis[N]; struct node { int x,y; }…
原题地址 题目大意 给定平面上的 $n$ 个点 $p_1, \dots, p_n$ .第 $i$ 点的坐标为 $(x_i, y_i)$ .$x_i$ 各不相同,$y_i$ 也各不相同.若两点 $p_i$ 和 $p_j$ 满足 $x_i < x_j$ 且 $y_i < y_j$ 则可配成一对.求这 $n$ 个点之中最多可配成多少对.(注:每个点最多出现在一个点对中) 解法 按 $y$ 坐标从大到小考虑.$y$ 值最大的点,不妨记为 $(x_i, y_i)$, 与 $x$ 坐标小于 $x_i$ 且…
题目大意 给定两个长为 $n$ 个整数序列 $a_1, \dots, a_n$ 和 $b_1, \dots, b_n$ .求所有 $a_i + b_j$($1\le i, j\le n$)的 XOR 值. 数据范围 $1\le n \le 200000$ $0\le a_i, b_j < 2^{28}$ 解法 这道题比赛时没想出来,赛后想到解法了. 我们的目标是求出这 $n^2$ 个数中有奇数个还是偶数个数的二进制第 $k$ 位为 $1$,而不必求出其中究竟有几个数的二进制第 $k$ 位为 $1…