随笔分类 -  实用数据结构

上一页 1 2

LA 3644 简单并查集
摘要:题目大意:有一些简单的化合物,每个化合物由两种元素组成,把这些化合物按顺序装车,若k个化合物正好包含k种元素,那么就会爆炸。避免爆炸,有些化合物就不能装车。求有多少个不能装车。题目分析:若k个化合物正好包含k种元素,那么就会爆炸。我们把每种元素看成一个顶点,每种化合物看成一条边,若有环存在的时候正好是爆炸的情况,所以避免成环记录不能放的数量就行了。#include#includeusing namespace std;const int maxn=100010;int f[maxn];int findset(int x){ return f[x]==x?x:f[x]=findset(f[x]) 阅读全文

posted @ 2014-02-24 17:07 雄.. 阅读(298) 评论(0) 推荐(0)

uva 11997 优先队列
摘要:K Smallest SumsYou're given k arrays, each array has k integers. There are kkways to pick exactly one element in each array and calculate the sum of the integers. Your task is to find the k smallest sums among them.InputThere will be several test cases. The first line of each case contains an in 阅读全文

posted @ 2014-01-27 13:53 雄.. 阅读(218) 评论(0) 推荐(0)

LA 3135 优先队列
摘要:题目大意:有若干命令,它有两个属性Q_Num,Period(周期)。按时间循序模拟前k个命令并输出他们的Q_Num,若同时发生输出Q_Num最小的值。#include#include#include#includeusing namespace std;struct Item{ int QNum,Period,Time; bool operator pq; while(scanf("%s",s) && s[0] != '#') { scanf("%d %d",&item.QNum,&item.Period) 阅读全文

posted @ 2014-01-27 11:54 雄.. 阅读(247) 评论(0) 推荐(0)

uva 11991 查询中容器的运用
摘要:题目大意:一个n个整数的数组,m条查询指令。(1#include#include#includeusing namespace std;map > a;int main(){ int n,m,i,p,k,v; while(scanf("%d %d",&n,&m) == 2) { a.clear(); for(i=0;i (); a[p].push_back(i+1); } while(m--) { scanf("%d %d",&k,&v); ... 阅读全文

posted @ 2014-01-27 11:07 雄.. 阅读(163) 评论(0) 推荐(0)

uva 11995 判别数据类型
摘要:Problem II Can Guess the Data Structure!There is a bag-like data structure, supporting two operations:1 xThrow an element x into the bag.2Take out an element from the bag.Given a sequence of operations with return values, you're going to guess the data structure. It is a stack (Last-In, First-Ou 阅读全文

posted @ 2014-01-26 13:49 雄.. 阅读(653) 评论(1) 推荐(0)

上一页 1 2

导航