Solution : At first you may have no idea of this subject,but there is a very ingenious train of thought. One thought would be to add two attributes of the same equipment,but this would be too hard to solve. So we have other thought : we can add the level of the attributes of the same equipment to the number of the equitment,then we use the bipartite graph. Because in the subject we can only use one attribute of one equipment && if we add  attributes level of the same equipment to the number of the equitment,the graph of the sample will be shown as below:

then we will realize that we can enumerate 1 ~ 10001(the attribute level) to run bipartite graph,if we can't find the equipment of that attribute level(there is no equipment of that level || that equipment used other attribute)then the answer is that attribute level - 1

code:

 #include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
using namespace std;
char buf[ << ];
char *p1 = buf;
char *p2 = buf;
template < class T >
inline void read(T & x)
{
x = ;
char c = getchar();
bool f = ;
for(; !isdigit(c); c = getchar())
{
f ^= c == '-';
}
for(; isdigit(c); c = getchar())
{
x = x * + (c ^ );
}
x = f ? -x : x;
return;
}
template < class T >
inline void write(T x)
{
if(x < )
{
putchar('-');
x = -x;
}
T y = ;
int len = ;
for(; y <= x / ; y *= )
{
++len;
}
for(; len; --len, x %= y, y /= )
{
putchar(x / y + );
}
return;
}
int n, choose[], vis[], num, head[], cnt;
struct node
{
int next, to;
}stu[];
inline void add(int x, int y)
{
stu[++num].next = head[x];
stu[num].to = y;
head[x] = num;
return;
}
inline int dfs(int u)//bipartite graph masterplate
{
for(register int i = head[u]; i; i = stu[i].next)
{
int k = stu[i].to;
if(vis[k] == cnt)//it is just the same as if(vis[k]),but we can't use memset(TLE) so we can only use this
{
continue;
}
vis[k] = cnt;//(self-understanding)
if(!choose[k] || dfs(choose[k]))
{
choose[k] = u;
return ;
}
}
return ;
}
signed main()
{
read(n);
for(register int i = , x, y; i <= n; ++i)
{
read(x);
read(y);
add(x, i);
add(y, i);
}
for(register int i = ; i <= ; ++i)//warning: to 10001 not to 10000(self-understanding)
{
//warning:you can't use memset here because that will TLE(O(10000 * n))
++cnt;//leave out the memset(self-understanding)
if(!dfs(i))
{
write(i - );
return ;
}
}
return ;
}

//2 hrs

最新文章

  1. 每天一个设计模式-2 外观模式(Facade)
  2. Android笔记——Android五大布局
  3. 闲扯淡json格式与对象
  4. Leetcode: Water and Jug Problem &amp;&amp; Summary: GCD求法(辗转相除法 or Euclidean algorithm)
  5. POJ 3207 Ikki&#39;s Story IV - Panda&#39;s Trick
  6. C++中的INL
  7. BZOJ_1626_[Usaco2007_Dec]_Building_Roads_修建道路_(Kruskal)
  8. java导入导出excel常用操作小结及简单示例
  9. IOS 获取通讯录中信息
  10. 按钮点击效果jquery
  11. 用webgl打造自己的3D迷宫游戏
  12. Java反射-中级知识掌握
  13. Python中的json模块
  14. openlayer3相关扩展
  15. Shell 编程中,在循环里使用ssh免密远程执行命令的注意事项
  16. mysql 数据库导入导出方法总结
  17. 第二阶段第六次spring会议
  18. PHP中防止SQL注入
  19. Hadoop记录-Hadoop集群添加节点和删除节点
  20. Macbook Pro安装Office 2016 for mac

热门文章

  1. 100天搞定机器学习|Day8 逻辑回归的数学原理
  2. JavaOOP 第二章继承
  3. .NET Core CSharp 中级篇 2-2 List,ArrayList和Dictionary
  4. powershell小脚本--批量添加用户属性----导出登录时间
  5. ByteBuf
  6. 用mongodb 固定集合实现只保留固定数量的记录,自动淘汰老旧数据
  7. 客户端埋点实时OLAP指标计算方案
  8. 学习TensorFlow的第一天
  9. 记一次IDEA 打包环境JDK版本和生产环境JDK版本不一致引发的血案
  10. java学习-NIO(四)Selector