UVALive 3644 X-Plosives】的更多相关文章

UVAlive X-Plosives 思路:    “如果车上存在k个简单化合物,正好包含k种元素,那么他们将组成一个易爆的混合物”  如果将(a,b)看作一条边那么题意就是不能出现环,很容易联想到Kruskal算法中并查集的判环功能(新加入的边必须属于不同的两个集合否则出现环),因此本题可以用并查集实现.模拟装车过程即可. 代码: #include<cstdio> #include<cstring> #define FOR(a,b,c) for(int a=(b);a<(c…
X-Plosives Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu [Submit]   [Go Back]   [Status] Description   X-Plosives A secret service developed a new kind of explosive that attain its volatile property only when a specific as…
思路:每一个product都可以作一条边,每次添加一条边,如果这边的加入使得某个集合构成环,就应该refuse,那么就用并查集来判断. AC代码: //#define LOCAL #include <stdio.h> #include <string.h> const int maxn = 1e5 + 5; int par[maxn], rank[maxn]; void init() { memset(rank, 0, sizeof(rank)); for(int i = 0; i…
A secret service developed a new kind of explosive that attain its volatile property only when a specific association of products occurs. Each product is a mix of two different simple compounds, to which we call a binding pair. If N > 2, then mixing…
uvaLive 3644:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1645 题意::每个化合物都是有两种元素组成的,如果车上存在k个简单化合物时,如果它和已装车的化合物形成易燃物的话,你就应该拒绝装车,否则装车,输出没有装车的个数 题解:一开始以为是与车上所有的化合物,所以直接用数组模拟打了一发.后来发现,是只要和部分…
题意: 有一些简单化合物,每个化合物都由两种元素组成的,你是一个装箱工人.从实验员那里按照顺序把一些简单化合物装到车上,但这里存在安全隐患:如果车上存在K个简单化合物,正好包含K种元素,那么他们就会组成一个容易爆炸的混合物,为了安全起见,每当你拿到一个化合物时,如果它已经和已装车的化合物形成了易爆混合物,你就应该拒绝装车,否则就应该装车,输出你拒绝了多少个混合物. 思路: 一种化合物由两种元素组成,所以我们就可以把每个元素看成一个点,那么一个简单化合物就是一条边.当图出现环的时侯,组成环的边对应…
UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug Description   The skyline of Singapore as viewed from the Marina Promenade (shown on the left) is one of the iconic scenes of Singapore. Country X would a…
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device with a variable electric resistance. It has two terminals and some kind of control mechanism (often a dial, a wheel or a slide) with which the resistance…
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here comes a problem about words. Know- ing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie. Since Jiejie can’t remem…
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000即为距离: 详细解释:http://www.cnblogs.com/zywscq/p/4268556.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath&…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4156 题目拷贝难度大我就不复制了. 题目大意:维护一个字符串,要求支持插入.删除操作,还有输出第 i 次操作后的某个子串.强制在线. 思路1:使用可持久化treap可破,详细可见CLJ的<可持久化数据结构的研究>. 思路2:rope大法好,详见:http…
Permutation Graphs Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 6508 #include<stdio.h> #include<string.h> ],a[],b[],c[],b1[]; long long num; void merg_sort(int a[],int l,int r) { int…
Boxes Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 6500 #include<stdio.h> #include<string.h> int main() { int T,m,n; int i,j,s; ][]; scanf("%d",&T); while(T--) { s=; sc…
题目链接:UVALive 6948  Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. #include <stdio.h> #include <iostream> #include <string.h> #define maxn 100 using namespace std; char str[maxn]; int num[maxn]; bool vis[m…
UVAlive 3135 Argus Argus Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description A data stream is a real-time, continuous, ordered sequence of items. Some examples include sensor data, Internet traffic, fin…
// 状压DP uvalive 6560 // 题意:相邻格子之间可以合并,合并后的格子的值是之前两个格子的乘积,没有合并的为0,求最大价值 // 思路: // dp[i][j]:第i行j状态下的值 // j:0表示不合并,1表示向下合并 // 一开始输入要修改一下,然后滚动数组优化 #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include &…
// 二分+最短路 uvalive 3270 Simplified GSM Network(推荐) // 题意:已知B(1≤B≤50)个信号站和C(1≤C≤50)座城市的坐标,坐标的绝对值不大于1000,每个城市使用最近的信号站.给定R(1≤R≤250)条连接城市线路的描述和Q(1≤Q≤10)个查询,求相应两城市间通信时最少需要转换信号站的次数. // 思路:建议先阅读 NOI论文 <<计算几何中的二分思想>> // 直接献上题解吧: // 二分! // l的两端点所属信号站相同:…
UVAlive 3026 Period 题目: Period   Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126, inclusive…
UVAlive 3942 Remember the Word 题目: Remember the Word   Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description Neal is very curious about combinatorial problems, and now here comes a problem about words. Kn…
UVAlive 4329 Ping pong 题目: Ping pong Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description N(3N20000) ping pong players live along a west-east street(consider the street as a line segment). Each player ha…
UVAlive 3027 Corporative Network 题目:   Corporative Network Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 3450   Accepted: 1259 Description A very big corporation is developing its corporative network. In the beginning each of the N ent…
UVAlive 4794 Sharing Chocolate 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=12055 思路:   设d[S][r][c]表示形如r*c的矩形是否可以划分为S中的子集,10表示可否. 转移方程: d[S][r][c] = d[S0][r0][c] || d[S0][r][c0]  优化:    首先注意到S r c三者知二求一,所以将状态优化为d[S][x]表示有短边x的矩形是否可以…
 UVAlive 3983 Robotruck 题目: Robotruck   Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description   Problem C - Robotruck Background This problem is about a robotic truck that distributes mail packages to sev…
UVAlive 4670 Dominating Patterns 题目:   Dominating Patterns   Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Submit Status Description The archaeologists are going to decipher a very mysterious ``language". Now, they kno…
3644 - X-Plosives A secret service developed a new kind of explosive that attain its volatile property only when a specificassociation of products occurs. Each product is a mix of two different simple compounds, to which wecall a binding pair. If N >…
经典的稳定婚姻匹配问题 UVALive - 3989 Ladies' Choice Time Limit: 6000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Submit]   [Go Back]   [Status] Description Problem I – LadiesÕ Choice Background Teenagers from the local high school have asked you to h…
题目 一开始有一个双头队列,每次添加一个数(这是数是二的幂,所有数的和不大于\(2^13\)),由你来决定添加到队头还是队尾.如果队列里面相邻的两个数相同,设它们都是\(x\),那么这两个数会合并为\(2x\).问所有数添加完后队列里能否只剩下一个数. 算法 搜索题,但是需要巧妙地记录状态!这种题不可多. 一个显然的是,队列里不会存在相邻的三个数\(a,b,c\),满足\(a>b,c>b\).这样的话,队列肯定是一个倒V字. 记状态\((i,j)\)为添加完前\(i\)个数,\(j\)是倒V左…
UVALive - 3263 That Nice Euler Circuit (几何) ACM 题目地址:  UVALive - 3263 That Nice Euler Circuit 题意:  给出一个点,问连起来后的图形把平面分为几个区域. 分析:  欧拉定理有:设平面图的顶点数.边数.面数分别V,E,F则V+F-E=2  大白的题目,做起来还是非常有技巧的. 代码: /* * Author: illuz <iilluzen[at]gmail.com> * File: LA3263.cp…
这个题目的深搜形式,我也找出来了,dfs(i,j)表示第i个人选到了第j个物品,但是我却无限RE了,原因是我的viod型深搜太过暴力,我当时定义了一个计数器,来记录并限制递归的层数,发现它已经递归到了1500层,加上限制后,WA了……后来学习了网上的方法,使用bool型的深搜,每一次选择都去跟题目中给的限制去比较,看这次选择有没有冲突,如果没有搜下一个,当搜到false的时候,及时停止,节省了时间和空间. 伪代码: if(dfs(next)==true) return true: else re…
树形背包.DP递推的思路很简单.... 但是由于节点有15万个,先不论空间复杂度,这样开dp数组 dp[150000+10][300+10],如果初始化是memset(dp,-1,sizeof dp),则必然超时. 所以需要一个状态数剪枝...即记录这个节点最多组合的数量. UVALive是不限制内存的,所以dp[150000+10][300+10] 能够AC,HDU 4169 限制了内存大小,需要优化空间复杂度. 内存优化之后的代码,HDU上C++能AC,G++依旧MLE. #include<…