BNUOJ 12756 Social Holidaying(二分匹配)
题目链接:http://www.bnuoj.com/bnuoj/problem_show.php?pid=12756
Social Holidaying
64-bit integer IO format: %lld Java class name: Main
None
Graph Theory
2-SAT
Articulation/Bridge/Biconnected Component
Cycles/Topological Sorting/Strongly Connected Component
Shortest Path
Bellman Ford
Dijkstra/Floyd Warshall
Euler Trail/Circuit
Heavy-Light Decomposition
Minimum Spanning Tree
Stable Marriage Problem
Trees
Directed Minimum Spanning Tree
Flow/Matching
Graph Matching
Bipartite Matching
Hopcroft–Karp Bipartite Matching
Weighted Bipartite Matching/Hungarian Algorithm
Flow
Max Flow/Min Cut
Min Cost Max Flow
DFS-like
Backtracking with Pruning/Branch and Bound
Basic Recursion
IDA* Search
Parsing/Grammar
Breadth First Search/Depth First Search
Advanced Search Techniques
Binary Search/Bisection
Ternary Search
Geometry
Basic Geometry
Computational Geometry
Convex Hull
Pick's Theorem
Game Theory
Green Hackenbush/Colon Principle/Fusion Principle
Nim
Sprague-Grundy Number
Matrix
Gaussian Elimination
Matrix Exponentiation
Data Structures
Basic Data Structures
Binary Indexed Tree
Binary Search Tree
Hashing
Orthogonal Range Search
Range Minimum Query/Lowest Common Ancestor
Segment Tree/Interval Tree
Trie Tree
Sorting
Disjoint Set
String
Aho Corasick
Knuth-Morris-Pratt
Suffix Array/Suffix Tree
Math
Basic Math
Big Integer Arithmetic
Number Theory
Chinese Remainder Theorem
Extended Euclid
Inclusion/Exclusion
Modular Arithmetic
Combinatorics
Group Theory/Burnside's lemma
Counting
Probability/Expected Value
Others
Tricky
Hardest
Unusual
Brute Force
Implementation
Constructive Algorithms
Two Pointer
Bitmask
Beginner
Discrete Logarithm/Shank's Baby-step Giant-step Algorithm
Greedy
Divide and Conquer
Dynamic Programming
Tag it!
Source
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int ss[],Map[][];
int ok[],vis[];
int a[],b[];
int n,m; bool Find(int x)
{
for (int i=; i<=n; i++)
{
if (!vis[i]&&Map[x][i]==)
{
vis[i]=;
if (!ok[i])
{
ok[i]=x;
return true;
}
else
{
if (Find(ok[i]))
{
ok[i]=x;
return true;
}
}
}
}
return false;
} int main()
{
int t;
scanf("%d",&t);
while (t--)
{
scanf("%d%d",&n,&m);
int ans=;
memset(vis,,sizeof(vis));
memset(Map,,sizeof(Map));
memset(ok,,sizeof(ok));
memset(ss,,sizeof(ss));
for (int i=; i<=n; i++)
{
scanf("%d",&a[i]);
}
for (int i=; i<=m; i++)
{
scanf("%d",&b[i]);
ss[b[i]]=;
}
for (int i=; i<=n; i++)
{
for (int j=i+; j<=n; j++)
{
if (ss[a[i]+a[j]]==)
Map[i][j]=Map[j][i]=;
}
}
for (int i=; i<=n; i++)
{
memset(vis,,sizeof(vis));
if (Find(i))
ans++;
}
printf ("%d\n",ans/);
}
return ;
}
BNUOJ 12756 Social Holidaying(二分匹配)的更多相关文章
- UVA5874 Social Holidaying 二分匹配
二分匹配简单题,看懂题意,建图比较重要. #include<stdio.h> #include<string.h> #define maxn 1100 int map[maxn ...
- POJ 1274 The Perfect Stall、HDU 2063 过山车(最大流做二分匹配)
The Perfect Stall Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 24081 Accepted: 106 ...
- [kuangbin带你飞]专题十 匹配问题 二分匹配部分
刚回到家 开了二分匹配专题 手握xyl模板 奋力写写写 终于写完了一群模板题 A hdu1045 对这个图进行 行列的重写 给每个位置赋予新的行列 使不能相互打到的位置 拥有不同的行与列 然后左行右列 ...
- BZOJ 1189 二分匹配 || 最大流
1189: [HNOI2007]紧急疏散evacuate Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1155 Solved: 420[Submi ...
- Kingdom of Obsession---hdu5943(二分匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5943 题意:给你两个数n, s 然后让你判断是否存在(s+1, s+2, s+3, ... , s+n ...
- poj 2060 Taxi Cab Scheme (二分匹配)
Taxi Cab Scheme Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5710 Accepted: 2393 D ...
- [ACM_图论] Sorting Slides(挑选幻灯片,二分匹配,中等)
Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he i ...
- [ACM_图论] The Perfect Stall 完美的牛栏(匈牙利算法、最大二分匹配)
描述 农夫约翰上个星期刚刚建好了他的新牛棚,他使用了最新的挤奶技术.不幸的是,由于工程问题,每个牛栏都不一样.第一个星期,农夫约翰随便地让奶牛们进入牛栏,但是问题很快地显露出来:每头奶牛都只愿意在她们 ...
- nyoj 237 游戏高手的烦恼 二分匹配--最小点覆盖
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=237 二分匹配--最小点覆盖模板题 Tips:用邻接矩阵超时,用数组模拟邻接表WA,暂时只 ...
随机推荐
- 第211天:git和github的区别和使用详解
一.git 1.什么是git 它是一个源代码管理工具,在一个项目中,凡是由开发人员编写的都算是源代码,源代码有必要管理起来,让源代码可以被追溯,主要记录每次变更了什么,谁主导这次变化.人为的维护比较麻 ...
- 为什么家里的宽带的IP显示的是外地?
作者:NightCoffee链接:https://www.zhihu.com/question/22547945/answer/21734955来源:知乎著作权归作者所有.商业转载请联系作者获得授权, ...
- MT【163】运动是相对的
如图,在平面直角坐标系中,$P(6,8)$,四边形$ABCD$为矩形,$AB=16$,$AD=9$,点$A,B$分别在射线$OP$和$Ox$上,求$OD$的最大值_______ ...
- AFO NOI2018退役——菜鸡一直是菜鸡
游记DAY -INF连续几天的模拟让我确信我就是菜鸡.以及相信yxd,sjq,cyl神犇一定能够稳了. DAY 0报道,天很热热热热热热热热热. DAY 1开幕式,杜子德很热热热热热热热热热. DAY ...
- Java之链表实现栈结构
package com.wzlove.stack; import java.util.Iterator; import java.util.NoSuchElementException; /** * ...
- 解题:BZOJ 4644 经典砂比题(雾
题面 初见线段树分治 (对我来说可不是什么经典题=.=) 把时间轴建出来一棵线段树,然后在对应的区间上打标记,最后把整棵树DFS一遍,到叶节点输出答案即可 (把最终答案开成全局的了调了半天 #incl ...
- bzoj2961&&bzoj4140 共点圆
题目描述 在平面直角坐标系中,Wayne需要你完成n次操作,操作只有两种: 1.0 x y.表示在坐标系中加入一个以(x, y)为圆心且过原点的圆. 2.1 x y.表示询问点(x, y)是否在所有已 ...
- lumen 单元测试的一些问题
1.一个 test 多个请求 如 $this->post,然后又 $this->post,我们会发现第二个请求中的请求参数是和第一个请求的参数是完全一样的,然后在 Controller ...
- Python【sys】模块和【hashlib】模块
import sysimport osprint(sys.platform) #判断操作系统,windows10输出win32print("sys.path:",sys.path) ...
- Git1:Git简介
目录 什么是版本控制系统 集中式版本控制系统 分布式版本控制系统 Git起源 Git特性 什么是版本控制系统 版本控制系统是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统.版本控制 ...