A secret service developed a new kind of explosive that attain its volatile property only when a specicassociation of products occurs. Each product is a mix of two different simple compounds, to which wecall a binding pair. If N > 2, then mixing N diff…
https://vjudge.net/problem/UVALive-3027 题意: 有n个结点,初始时每个结点的父节点都不存在.你的任务是执行一次I操作和E操作,格式如下: I u v:把结点u的父节点设为v,距离为|u-v|除以1000的余数.输入保证执行指令前u没有父节点. E u:询问u到根结点的距离. 思路: 主要思想是并查集,记录一下每个结点到根结点的距离即可. #include<iostream> #include<cstring> using namespace…
有N个结点 一次 I u v 操作表示把结点u的父结点设为v,距离为|u-v|%1000.输入保证执行指令前u没有父结点 一次E u 操作表示询问u到根结点的距离 O操作表示结束 #include<iostream> #include<cstring> #include<cmath> using namespace std; ; int T,n,level,d[maxn],fa[maxn]; void init() { memset(d,,sizeof(d)); ;i&…
题目大意:有一些简单的化合物,每个化合物由两种元素组成,把这些化合物按顺序装车,若k个化合物正好包含k种元素,那么就会爆炸.避免爆炸,有些化合物就不能装车.求有多少个不能装车. 题目分析:若k个化合物正好包含k种元素,那么就会爆炸.我们把每种元素看成一个顶点,每种化合物看成一条边,若有环存在的时候正好是爆炸的情况,所以避免成环记录不能放的数量就行了. #include<iostream> #include<cstdio> using namespace std; ; int f[m…
A very big corporation is developing its corporative network. In the beginning each of the N enterprises of the corporation, numerated from 1 to N, organized its own computing and telecommunication center. Soon, for amelioration of the services, the…
Corporative Network Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Submit] [Go Back] [Status] Description A very big corporation is developing its corporative network. In the beginning each of the N enterprises of th…