紫书
Serene-shixinyi
这个作者很懒,什么都没留下…
展开
-
Shuffle的播放记录Shuffle
//紫书P247//UVA12174Shuffle//Serene#include#include#include#include#include#includeusing namespace std;const int maxn=100000+10;int T,s,n,a[maxn],visnum[maxn],l=0;bool visans[maxn];int原创 2017-03-06 20:30:53 · 225 阅读 · 0 评论 -
最优矩阵链乘 Multiplication Puzzle
Multiplication PuzzleTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9697 Accepted: 6023DescriptionThe multiplication puzzle is played with a row of car原创 2017-03-27 12:48:49 · 219 阅读 · 0 评论 -
切木棍 Cutting Sticks
简单的dp//Serene//紫书p278 切木棍 Cutting Sticks #include#include#include#include#include#includeusing namespace std;const int maxn=50+10;int l,n,p[maxn],dp[maxn][maxn];int aa;char c;int read()原创 2017-03-27 14:35:56 · 459 阅读 · 0 评论 -
求树的重心
DescriptionConsider a tree T with N (1 <= N <= 20,000) nodes numbered 1...N. Deleting any node from the tree yields a forest: a collection of one or more trees. Define the balance of a node to be原创 2017-03-27 15:30:05 · 206 阅读 · 0 评论 -
树的最长路
描述上回说到,小Ho得到了一棵二叉树玩具,这个玩具是由小球和木棍连接起来的,而在拆拼它的过程中,小Ho发现他不仅仅可以拼凑成一棵二叉树!还可以拼凑成一棵多叉树——好吧,其实就是更为平常的树而已。但是不管怎么说,小Ho喜爱的玩具又升级换代了,于是他更加爱不释手(其实说起来小球和木棍有什么好玩的是吧= =)。小Ho手中的这棵玩具树现在由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了原创 2017-03-27 16:12:33 · 288 阅读 · 0 评论 -
装满水的气球 Dropping water balloons
你有k个一模一样的水球,在一个n层楼的建筑物上进行测试,你想知道水球最低从几层楼往下丢可以让水球破掉。你想丢最少次水球来测出水球刚好破掉的最低楼层。(水球可能在顶楼也不会破)你可以在任意楼层丢下水球来测试,如果水球没破,你可以继续用它。输入的每一行包含多组测试,每组测试为一行。每组测试包含两个整数 k 和 n, 1 对于每次测试,输出在最糟情况下,测出水球破掉楼层的最少次数。如果多于63次原创 2017-03-28 21:33:02 · 410 阅读 · 0 评论 -
20个问题 Twenty Questions
状压dp 记忆化搜索s表示当前已经询问的特征,x表示目前物品已经询问过的特征中所具备的特征//Serene//紫书p287 20个问题 Twenty Questions #include#include#include#include#include#includeusing namespace std;const int maxm=12,maxn=(1<<7)+10,I原创 2017-03-28 11:12:08 · 611 阅读 · 0 评论 -
生成排列 Generating Permutations
逆向思考。操作1不变,操作2等价于将尾部数字放到头部,这样最后只需要逆序输出操作序列即可。具体做法把序列看作环状的,每次操作2就等价于移动头部的位置,用操作1每次维护头部的最小元素,再执行操作2。这个过程类似于排序,当a[0]==1或n时就不做操作1(a[0]==n时这时的头部进行多次操作2最终会变为尾部)。//紫书P254 生成排列 //Serene#include#include#原创 2017-03-07 21:59:45 · 328 阅读 · 0 评论 -
洞穴 Cave
//紫书P249洞穴Cave//Serene#include#include#include#include#include#includeusing namespace std;const int maxn=1e6+10;int Q,n,fl[maxn],ce[maxn],ans[maxn];int aa=0;char c;int read() { aa=0;c=ge原创 2017-03-07 10:30:12 · 385 阅读 · 0 评论 -
奖品的价值 Erasing and Winning
//紫书P253 奖品的价值 //Serene#include#include#include#include#include#include#include#includeusing namespace std;const int maxn=1e5+10;int n,d,r;int a[maxn];deque Q;int aa;char c;int read()原创 2017-03-07 20:41:13 · 237 阅读 · 0 评论 -
比特变换器 Bits Equalizer
//紫书p253 比特变换器 //Serene#include#include#include#include#include#includeusing namespace std;int Q,s[110],r1,r2,r3,r4,ans;char hh[120];int main() { scanf("%d",&Q); for(int qaq=1;qaq<=Q;++q原创 2017-03-07 17:38:30 · 301 阅读 · 0 评论 -
聚会游戏 Party Games
这题主要要注意细节问题,特别是排序后a[n/2]的长度>a[n/2+1]的情况和有后面有Z的情况下面给个用来调试的样例:INPUT:2ABCABB2ABCABBA2ABCABBZAB2ABBZZAABC0OUTPUT:ABBABBAABBZBABBZZA//紫书P253聚会游戏//Serene#include#i原创 2017-03-07 16:30:27 · 472 阅读 · 0 评论 -
装箱Bin Packing
//紫书P253 装箱//Serene#include#include#include#include#include#includeusing namespace std;const int maxn=2e5+10;int Q,n,l,w[maxn];bool vis[maxn];int aa=0;char c;int read() { aa=0;c=getchar(原创 2017-03-07 13:07:48 · 417 阅读 · 0 评论 -
防线Defense Lines
//紫书P242//UVA1471Defense Lines//Serene#include#include#include#include#include#include#includeusing namespace std;const int maxn=2e5+10;int t,n,a[maxn],f[maxn],g[maxn];原创 2017-02-28 15:38:21 · 213 阅读 · 0 评论 -
划分成回文串 Partitioning by Palindromes
简单的dp//Serene//紫书p275 划分成回文串 Partitioning by Palindromes#include#include#include#include#include#includeusing namespace std;const int maxlen=1000+10;int n,j,len;bool sf[maxlen][maxlen];int原创 2017-03-27 11:17:46 · 473 阅读 · 0 评论