HDU 5818:Joint Stacks(stack + deque)】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=5818 Joint Stacks Problem Description   A stack is a data structure in which all insertions and deletions of entries are made at one end, called the "top" of the stack. The last entry which is inserted i…
HDU 5818 Joint Stacks(联合栈) Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Description 题目描述 A stack is a data structure in which all insertions and deletions of entries are made at one end, called the "top" of…
Joint StacksCrawling in process... Crawling failed Time Limit:4000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5818 uDebug Description   Input   Output   Sample Input   Sample Output   Hint   Description A…
http://acm.hdu.edu.cn/showproblem.php?pid=2732 题意:给出两个地图,蜥蜴从一个柱子跳跃到另外一个地方,那么这个柱子就可能会坍塌,第一个地图是柱子可以容忍跳跃多少次(即从它为起点可以跳跃多少次,然后坍塌),第二个地图是蜥蜴的位置.还有一个跳跃距离d,即蜥蜴可以跳跃不超过d的距离(曼哈顿距离),如果跳到地图外面,即蜥蜴逃跑成功,问最终留下的蜥蜴数最少是多少. 思路:我觉得如果不是在做网络流套题应该想不到这是网络流.其实挺简单的建图.首先考虑蜥蜴的位置,和…
http://acm.hdu.edu.cn/showproblem.php?pid=4055 题意:给一个仅包含‘I','D','?'的字符串,’I'表示前面的数字比后面的数字要小(Increase升序),'D'表示前面的数字比前面的数字要大(Decrease降序),'?'表示有可能是'I'也有可能是'D',长度为n的字符串就有n+1个数字,在这n+1个数字里面,问符合给出的字符串的条件的序列数有多少种. 思路:dp[i][j]的定义:i表示当前枚举到第i个字符(即长度为i+1的时候的序列),j…
题目:这里 题意: 两个类似于栈的列表,栈a和栈b,n个操作,push a x表示把数x放进a栈的栈底,pop b 表示将栈b的栈顶元素取出输出,并释放这个栈顶元素,merge a b表示把后面的那个 栈里的元素全部压进前面的那个栈里面,并且压入后前面的栈的所有元素按其进栈顺序排列然后后面的栈变为了空. push和pop操作都还好,就是优先队列或者栈的操作,主要是merge操作,如果啊按照题目来模拟每次将后面的栈元素取出放入前面的栈,可能会超时,而超时的主要因素是每次都将 元素多的栈压入了元素少…
http://acm.hdu.edu.cn/showproblem.php?pid=5898 题意:给出一个区间[l, r],问其中数位中连续的奇数长度为偶数并且连续的偶数长度为奇数的个数.(1<=L<=R<= 9*10^18) 思路:在比赛的时候只大概记得是怎么写的,但是就是不会写,虽然写过好几道可还是写不出来.回去后重新写又错了几次,主要前导零的情况没有考虑清楚.存的时候存长度和之前一位是偶数还是奇数和是否有前导零.然后根据条件判断才写了出来. #include <cstdio…
http://acm.hdu.edu.cn/showproblem.php?pid=4417 题意是:给出n个数和q个询问,每个询问有一个l,r,h,问在[l,r]这个区间里面有多少个数是小于等于h的. 思路:比较裸的主席树,注意题意给的区间是从[0,n-1],一开始看错导致想错了很多东西.询问的时候如果m < h,那么左子树全部都是小于 h 的,就加上左子树的 sum,继续查右子树,否则就查左子树.最后 l == r 的时候要判下 h >= l,因为这个也错了几次.从师兄那里学习到了如果找一…
http://acm.split.hdu.edu.cn/showproblem.php?pid=1520 Anniversary party Problem Description   There is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It me…
子串查询 Time Limit: 3500/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 633    Accepted Submission(s): 301 Problem Description 度度熊的字符串课堂开始了!要以像度度熊一样的天才为目标,努力奋斗哦! 为了检验你是否具备不听课的资质,度度熊准备了一个只包含大写英文字母的字符串 A[1,n]=a1a…
产生冠军 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 21762    Accepted Submission(s): 9864 Problem Description 有一群人,打乒乓球比赛,两两捉对撕杀,每两个人之间最多打一场比赛. 球赛的规则如下: 如果A打败了B,B又打败了C,而A与C之间没有进行过比赛,那么就认定,A一定能…
http://acm.hdu.edu.cn/showproblem.php?pid=2089 不要62 Problem Description   杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer). 杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众. 不吉利的数字为所有含有4或62的号码.例如: 62315 73418 88914 都属于不吉利号码.但是,61152虽然含有6和2…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5787 题意:要求相邻的K个位的数不能相同,在[L,R]区间有多少个这样的数. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ]; ][][][][]; int k; //考虑前导零:d = 10代表前一位是0, 当(d == 10 &&…
饭卡 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 41634    Accepted Submission(s): 14250 Problem Description 电子科大本部食堂的饭卡有一种很诡异的设计,即在购买之前判断余额.如果购买一个商品之前,卡上的剩余金额大于或等于5元,就一定可以购买成功(即使购买后卡上余额为负),否则…
http://acm.hdu.edu.cn/showproblem.php?pid=2896 题意:中文题意. 思路:AC自动机模板题.主要在于字符有128种,输出还要排序和去重! 注意是“total”不是“totol”!!!因为这个Debug了好久. 还有结点是new的,不然MLE. 主要用来测试模板,看了两个,发现没有注释掉的效率高点. #include <cstring> #include <algorithm> #include <cstdio> #includ…
http://acm.hdu.edu.cn/showproblem.php?pid=5763 Another Meaning Problem Description   As is known to all, in many cases, a word has two meanings. Such as “hehe”, which not only means “hehe”, but also means “excuse me”. Today, ?? is chating with MeiZi…
Two Paths Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 153428/153428 K (Java/Others) Total Submission(s): 2184 Accepted Submission(s): 856 Problem Description You are given a undirected graph with n nodes (numbered from 1 to n) and m edges. A…
Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 48378    Accepted Submission(s): 22242 Problem Description A subsequence of a given sequence is the given sequence with some e…
一个包含四个点的完全图,可以在任意节点出发,可以在任意节点结束,给出每个点被经过的次数,求有多少种合法的遍历序列.如果两个序列至少有一位是不同的,则认为它们不相同. Input 2 3 3 3 Sample Output 12336 题意:给a个A,b个B,c个C,d个D,求有少种排列,使得相邻的两个不同. 思路:用容斥来做,ans=所有排列-至少一个相邻+至少两个相邻-...+.... 假设有i堆a,则方案数位C(a-1,i-1),则a中至少a-i个相邻:同理: 则i堆a,j堆b,k堆c,l堆…
Alice is interesting in computation geometry problem recently. She found a interesting problem and solved it easily. Now she will give this problem to you : You are given NN distinct points (Xi,Yi)(Xi,Yi) on the two-dimensional plane. Your task is to…
题目链接 题意 给出一个n个结点的树,给出n-1个度的权值f[],代表如果一个点的度数为i,那么它对于答案的贡献有f[i].问在这棵树最大的贡献能达到多少. 思路 对于这个图,有n*2-2个度可以分配(看成一条链的形状),首先可以确定n个点,那么每个点都是要分配一个度的,因此现在有n个f[1],还有n-2个度没有分配.那么这n-2就可以当做背包容量,对于每一种度,像完全背包一样去枚举用多少种最优. #include <bits/stdc++.h> using namespace std; ty…
Just Random Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3932 Accepted Submission(s): 1276 Problem Description Coach Pang and Uncle Yang both love numbers. Every morning they play a game with n…
题目链接 题意 给出p块钱,现在要用十种硬币凑出,每种硬币有c[i]个,问最多能用多少个硬币. 思路 首先确定,对于每个硬币就是能用小的替换就不用大的. 所以,可以先把硬币尽量用小的替换,如果小的不够用,再用大的去替换. 根据这个思路,就可以处理出一个前 i 个硬币总价值的前缀和 pre[],从大的面额到小面额去枚举,当前这种面额的硬币至少需要使用 (sum - pre[i-1]) / val[i] 种,sum代表当前还剩下多少钱要去兑换,这个数要向上取整,然后继续dfs下去就可以了. 还有一种…
题目链接 题意 给出n个点m条边的无向图,求次短路. 思路 和 POJ 2449 类似,只不过大小要开成long long. #include <bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100011; const int INF = 0x3f; struct Edge { int v, nxt; LL w; } edge[N*2]; struct Node { int u; LL g, h;…
HDU 3496 Watch The Movie(看电影) Time Limit: 1000MS   Memory Limit: 65536K [Description] [题目描述] New semester is coming, and DuoDuo has to go to school tomorrow. She decides to have fun tonight and will be very busy after tonight. She like watch cartoon…
HDU 5224 Tom and paper(最小周长) Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Description There is a piece of paper in front of Tom, its length and width are integer. Tom knows the area of this paper, he wants to know th…
HDU 5868 Different Circle Permutation(burnside 引理) 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5868 Description You may not know this but it's a fact that Xinghai Square is Asia's largest city square. It is located in Dalian and, of course, a landm…
m_Orchestrate learning system---三十五.php数据和js数据的解耦:php数据(php代码)不要放到js代码中 一.总结 一句话总结:也就是以html为中介,用html存储数据,用js取数据 html 存 js 取 html 中介 json JSON.parse() html() 可以放在div标签里面,js中使用的时候直接找到这个div拿就可以了 也就是以html为中介 用html存储数据 <div id="fry_analyze_record_graph…
由于信道管理器在客户端和服务端所起的不同作用,分为信道监听器和信道工厂.和服务端的信道监听其相比,处于客户端的信道工厂显得简单.从名称就可以看得出来,信道工厂的作用就是单纯的创建用于消息发送的信道.我们先来看看与信道工厂相关的一些接口和基类的定义. 一.信道工厂相关的接口和基类 对于信道监听器,WCF定义了两个接口:IChannelListener和IChnnelListener<TChannel>.与之相对地,WCF也为信道工厂定义了两个接口:IChannelFactory和IChannel…
题目链接:pid=3131">HDU 3131 One-Two-Five! (暴力搜索) 题意:给出一串数字,要求用加,减,乘,除(5/2=2)连接(计算无优先级:5+3*6=8*6=48),求全部结果中,含有'3'且该数字出现频率最大.若频率相等,输出数字最大的. 暴力解决之 AC代码: #include <stdio.h> #include <map> #include <string.h> #include <algorithm> #d…