おかえしび~すと!!攻略&过关感想
攻略:
基本上不必攻略,0哄+后来闯哥哥房间可出兽娘和哥哥H的cg。爆1线出clear flag。两线都爆以后每条线都可攻略温泉路线(乒乓球的选择是忽悠人的)。最后在前面适当调配哄和不哄就能出全cg了。
感想:
惊呼。。。雷- - 当然偶不怎么萌兽娘,所以要是真心萌兽娘的话这作品可能还不错。兽娘的吐槽还算是个亮点,不过相对于剧情容量来说H的容量有点多了,感觉剧情还是有些缺。
在人物感想之前先谈一下cv。这作男主有cv(大惊)……结果是个弱气受(大雷),要不是哥哥还算过得去,偶就要把男声给关掉了。
人物线:
ひなた:爷爷家小狗的魂和附近神社的狛犬融合的化身,但是虽然化身成了娘,脾气却还是犬。筷子用不来生活费不知道是什么东西(天然纪念物?)。即使这样,她却有着很强大的灵力,招致了恶灵来袭击她(普通线附身在她自己身上,温泉线附身在美紀男身上强H了她)。当然,在美紀男的帮助下(虽然偶非常怀疑那个是不是帮助)事件解决。
梓:曾经是狐狸,曾经因为寻找给母亲(<--还是狐狸)治病的药草而困在了陷阱里,被美紀男所救,并且得到了药草。娘化后为了报恩便四处寻找他。性格还是狐狸,脑子动得很快,但有的时候还是会害羞(蹭?)。但是她自己的部落(狐狸群)却十分厌恶人类,让梓陷入危机(普通线袭击了美紀男并强制把梓带回部落,温泉线长老的灵魂化身了触手),当然最后事件还是很奇怪的解决了。
posted @
2009-01-20 07:23 Fancy Mouse的Blog 阅读(28) |
评论 (0) |
编辑
攻略:
要去good end必须11月以前把女仆们调教到及格线以上(10月是最后一次制订计划)。每个月初制定计划的时候可以根据当前状态制订计划,缺啥补啥(状态不影响路线,除非最后没到及格线;估计不影响剧情文本,不过这个偶自己没有确认)。个别指导的女仆,指数上升的更快。一般而言在这期中考试前指导白羽1次,其他都给朱里,还能有1次空余的指导。学习内容缺啥补啥就可以了。注意如果8月底以前没有到一个中间标准线的话会去另一个bad end。当然,如果好好指导朱里的话这就不会发生了。
保证进good end以后,进入4人的哪个分支取决于2件事。第一,此人物在先前半年的剧情最好一个不漏。第二是10月的character select。这里一般都是特选所需要攻略的女仆的路线,没有可选的时候一律回家洗洗睡。(注意有的时候ライラ会出现在自己家的图标上,如果这时候同时有回家洗睡的选项的话,两个选项是不一样的)。另外,后宫结局也是在这里,不过暂时不清楚具体如何确保进入,只知道这也和10月人物选择有关。
感想:
很赞!虽然作画并不是十分出彩,但是整个剧情很欢乐也很吸引人,值得入Z!
以下每个人的感想都取自共通线以及人物线
ライラ:蹭得累+腹黑女仆。很让人吃惊的是ライラ早年丧双亲,全家1个奶奶和8个孩子。作为最年长的姐姐,ライラ必须担当起家长的责任。于是ライラ便来到了女仆学校,希望靠成为女仆养家糊口。当然由于奶奶对她十分严厉使ライラ形成了说话刁钻的习惯,这个态度对于女仆来说很那啥……于是ライラ考试不及格,成为一个だめメイド并入Fledge班,接受秋人的再生指导。ライラ一开始对秋人这个临时主人十分讨厌,后来就因为秋人一些温柔的举动就蹭起来了>.< 用秋人的话说,ライラ就像只猫一样。最后ライラ当然从Fledge班顺利毕业,她也如愿成为秋人的女仆。只是这不是一般的女仆……碰到秋人和其他女人有所亲近马上出手。说白了,表メイド里つま>.<
フィリネ:名门富豪家的独生女。以经常ひゃく(打嗝)以后出现运气不好的事著称(至少Fledge班里的和秋人都知道- -)。本来也该是去大小姐学校的,结果也是因为坏运气,投档到了这个小椎尾私立女仆学园,家里怎么努力都取消不了。一开始毫无人生目标,把自己比喻成灾星。考试也因为奇怪的事件不及格进入Fledge班。当然在秋人的开导下渐渐意识到运气不好不一定意味着不幸,也许就在另一种意义上就是幸福,也许就把周围人的坏运气给吸过来消耗掉,等等(RP守恒?>.<)。于是フィリネ心中有了一个目标,成功从女仆学校毕业,而且不顾家里人反对,成了某家人的女仆。最终秋人也意识到自己对フィリネ的心意,送了她订婚戒指,按她的话说她就是个Engage maid了。而这时,偶们也知道了那时候她心中定下的目标——从此以后永远和秋人在一起。
朱里:口头禅是几乎所有话最后都要加です。学园女仆长ウィストル的妹妹,然则能力上和姐姐一个天上一个地下……她几乎干啥崩啥,唯一拥有的就是干劲。无论同年级的ュニス怎么挖苦,她依然干劲十足,希望能成为姐姐一样出色的女仆。她的努力影响了周围的其他Fledge,她的干劲几乎就成为整个Fledge班级的动力的来源。然而,她每次却都缺乏自信,因为以前干啥崩啥所以对自己非常没有信心。在刚被选为班级代表的时候她也再三推却,最终在“你希望成为像你姐姐一样的女仆吧”的理由下勉强接受了。在某种程度上说过度的努力下,朱里渐渐能够独自完成各种工作,并且能做出很美味的巧克力(虽然形状很囧)。然而,她的乐观和干劲却一直没变。大概,这就是她的魅力吧。最后,秋人和朱里都留在了学校,朱里在为成为姐姐——女仆长的接班人而努力着。顺带一句,朱里的动物形象是只小狗>.< 对主人百依百顺……之流,很囧。
白羽:来自一个保镖家族,从小就接受了保镖的训练,擅长刀和(发子弹的)枪。也因此,她缺乏和人的交流能力,一直都是那么无口。而且,她还极其怕虫,一看到虫马上就进入暴走状态- - 但是,也正因此,她感觉十分的寂寞。秋人看中了她对料理很感兴趣这点,鼓励她料理也是一种人和人的交流,鼓励她借此机会学习如何交流。同时,秋人让白羽负责学园祭的Fledge班级的活动——也就是说她需要和其他3个女仆需要进一步的交流。渐渐的,白羽学会了如何和人共处。而且,她自己也明白了自己对秋人的心意,毕业以后要求和秋人在一起。当秋人问起她原来的主人怎么办的时候,她就回答,“断る”- - 果然是个强气无口loli。
ハーレム(后宫)end:众人期中考试时就毕业,3个月后4人提出要求要当秋人的女仆(ライラ和白羽的理由很搞笑啊),并且紫先斩后奏地从秋人的妹妹秋纱那里拿到了秋人房间的钥匙并被给了4个人(秋人被摆了一道XD)。然后鬼使神差的ユニス,ミコ,マコ也被推倒以后,7个人就全部成为了秋人的后宫- -
bad end 1(8月end):草柳顺子的连珠炮是唯一的亮点。
音乐鉴赏:
MISS YOU(op): http://music.fenbei.com/13026409
Moving Love(ed): http://music.fenbei.com/13026496
おしえて ご主人様(special ed,2:02处自重): http://music.fenbei.com/13026787
posted @
2008-09-14 06:28 Fancy Mouse的Blog 阅读(313) |
评论 (2) |
编辑
1005
I Think I Need a Houseboat
纯吐槽……为什么不是Nice Boat- -|||
1022
Packing Unit 4D Cubes
先Floodfill填充内部格,然后一个面构成表面的充要条件是它一侧属于方块另一侧不属于方块。
1029
False coin
根据每次操作,判断每一颗coin是否可能偏重,是否可能偏轻。然后总体判断。
1031
Fence
光源在多边形内部则2*pi的弧度都被照到,否则只能照部分弧度。在算部分弧度的时候要小心,可能会按照算法算出来大于2*pi的情况的。这需要特判。
1034
The dog task
二分匹配,一段Bob的路径匹配一个景点。
1036
Gangsters
dp。方程是显然的,实现的时候需要离散化+滚动。离散化是对gangster到达时间进行离散,dp状态转移的时候也就适当扩大max查询范围大小就可以了。为了达到最好的效率,可采用Sparse Table结构来完成查询操作。
1037
A decorative fence
dp。方程是显然的,实现的时候需要离散化+滚动。离散化是对gangster到达时间进行离散,dp状态转移的时候也就适当扩大max查询范围大小就可以了。为了达到最好的效率,可采用Sparse Table结构来完成查询操作。
1041
John's trip
从起点开始每个点按边序号递增顺序DFS。
1043
What's In A Name?
名字和id去二分匹配。再求最大匹配中的边是否是必须的(即去掉后会导致匹配数减少),如果是,名字就和id匹配上。
1045
Bode Plot
根据有关交流电的知识,可以得到VR^2 + (VR*w*C*R)^2 == (V*w*C)^2
1054
The Troublesome Frog
注意Frog的稀疏性。搜索时只需有序存下所有Frog的位置然后判是否存在的时候用二分即可。
以下7题(1069~1075)是臭名昭著的Tehran2001题。除较水的1075外题解见下
1069
The Bermuda Triangle
首先,三角形的存储方式如下:
//暂缺图
在这个图里可以看到,六边形相当于变成了2n*2n的二维格点,这二维格点中缺了2个n*n的等腰直角三角形
数据结构通了以后基本上这题裸搜就能过了,DFS的时候预先保存一下当前位置最大能放个多大的三角形,而不是每次轮到搜了再去判是否合法。这样就能过了,至少偶就这样过掉的。
1070
Deformed Wheel
恶心的计算几何模拟。
算法很简单,每次二分,得到最大滚动的角度。然后滚过去以后,改变支撑点,继续滚,直到没法滚为止。
但这题的精度十分恶心。所有的地方都采用同一个epsilon的话一般会出问题。关键原因是这里有三角函数这个精度十分不准的东西,因此需要采用不同量不同对待,对于二分的滚动角度,精度取高一点(偶取1e-9),否则滚动误差太大的话再+个三角函数误差就wa了。对于取三角函数以后的值(即,滚动以后各顶点的新值),这个精度需要取得弱一些(偶取1e-6),否则滚动角度的精度在三角函数的制约下无法达到想要的较高的精度。
当然,可能是偶做得弱了。大牛若可以单epsilon搞定欢迎留言。
1071
Illusive Chase
相对来说一道水题。倒推,求每一步可能由哪些格子走过来,裸dp就可以了。
1072
Puzzle Out
为了满足poj那bt的5s(tehran是120s,tokyo是180s,zoj是10s),Trie的存储是必须的。其次,Trie的存储又是可能会mle的,所以偶只得采取左儿子右兄弟的存储方式,来节省原来数组node表示法里在叶节点浪费的那些内存(浪费的是搜索的时候的时间)。
这样程序跑进了3s内。
然后再取待测字串里公用字符最多的进入dfs,可以跑进1.2s内。
接下来就歪门了……通过适当的挑选第一个开始搜的词(偶没发现啥规律……纯粹按照数据给的来枚举出最快的),可以跑进0.5s内。这时单数据最大的搜索量(dfs调用次数)不超过30w。。。也算是不错的成绩了。如果把常数弄小点的话估计rank能更高些。。。不过偶实在是没这兴趣也没这能力了。。。
p.s. Google了一下,HNU居然是1s的时限orz……然后是0人ac。。。
1073
The Willy Memorial Program
还是恶心模拟。两个管连通以后就可以视作合并成1个管,截面积相加。
细节方面,主要要把过程分为如下2个模块:
1.确定真正的初始管。因为可能存在a的底部连到b管的情况。这样如果a作为源的话事实上当b没满的时候a是不可能有积水的。因此初始时应当把b看作源而不是a。这样的好处是对于源,每次加水肯定会导致源的水位上涨。
2.合并管道。当水位上到某个连通器的时候两侧的管可以合并。
然后放心大胆地调用就可以了。数据规模不大,合并也根本没有并查集的必要。裸干就可以了。
1074
Parallel Expectations
标准dp。思路lrj的黑书已经给出。注意黑书上对于题意的理解是错的。真正等概率分布的是每一步跑哪个核(当两个核都能跑的时候各50%)而不是所有程序执行的排列(每个排列等概率)。仔细体会里面的不同。这样,只需要在dp以前求出该情况的概率即可。而这可以和dp数组的计算同步进行。
1076
Bowl
/*Still Under Construction*/
posted @
2008-06-26 00:10 Fancy Mouse的Blog 阅读(739) |
评论 (2) |
编辑
Vol 1, 1000~1099
| 1000 |
1001
|
1002
|
1003
|
1004
|
1005
|
1006
|
1007
|
1008
|
1009
|
ac
|
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
| 1010 |
1011
|
1012
|
1013
|
1014
|
1015
|
1016
|
1017
|
1018
|
1019
|
| |
ac |
ac |
ac |
ac |
|
ac |
ac |
ac |
ac |
| 1020 |
1021
|
1022
|
1023
|
1024
|
1025
|
1026
|
1027
|
1028
|
1029
|
| ac |
|
ac |
ac |
|
|
ac |
|
ac |
ac |
| 1030 |
1031
|
1032
|
1033
|
1034
|
1035
|
1036
|
1037
|
1038
|
1039
|
| |
ac |
ac |
|
ac |
wa |
ac |
ac |
ac |
|
| 1040 |
1041
|
1042
|
1043
|
1044
|
1045
|
1046
|
1047
|
1048 |
1049
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
ac |
| 1050 |
1051
|
1052
|
1053
|
1054
|
1055
|
1056
|
1057
|
1058
|
1059
|
| ac |
ac |
wa |
ac |
ac |
|
ac |
|
ac |
ac |
1060
|
1061
|
1062
|
1063
|
1064
|
1065
|
1066
|
1067
|
1068
|
1069
|
| ac |
ac |
ac |
ac |
ac |
ac |
|
ac |
ac |
ac |
| 1070 |
1071 |
1072
|
1073
|
1074
|
1075
|
1076
|
1077
|
1078
|
1079
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
1080
|
1081
|
1082
|
1083
|
1084
|
1085
|
1086
|
1087
|
1088
|
1089
|
| ac |
ac |
ac |
ac |
ac |
|
ac |
|
ac |
ac |
1090
|
1091
|
1092
|
1093
|
1094
|
1095
|
1096
|
1097
|
1098
|
1099
|
| |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
ac |
1100
|
1101
|
1102
|
1103
|
1104
|
1105
|
1106
|
1107
|
1108
|
1109
|
| ac |
|
ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
1110
|
1111
|
1112
|
1113
|
1114
|
1115
|
1116
|
1117
|
1118
|
1119
|
| ac |
ac |
ac |
ac |
|
ac |
|
ac |
ac |
ac |
| 1120 |
1121
|
1122
|
1123
|
1124
|
1125
|
1126
|
1127
|
1128
|
1129
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
1130
|
1131
|
1132
|
1133
|
1134
|
1135
|
1136
|
1137
|
1138
|
1139
|
| ac |
ac |
|
|
ac |
ac |
|
|
|
ac |
1140
|
1141
|
1142
|
1143
|
1144
|
1145
|
1146
|
1147
|
1148
|
1149
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
1150
|
1151
|
1152
|
1153
|
1154
|
1155
|
1156
|
1157
|
1158
|
1159
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
ac |
1160
|
1161
|
1162
|
1163
|
1164
|
1165
|
1166
|
1167
|
1168
|
1169
|
| ac |
ac |
|
ac |
ac |
tle |
ac |
ac |
wa |
ac |
1170
|
1171
|
1172
|
1173
|
1174
|
1175
|
1176
|
1177
|
1178
|
1179
|
| ac |
ac |
ac |
ac |
ac |
ac |
ac |
|
ac |
ac |
1180
|
1181
|
1182
|
1183
|
1184
|
1185
|
1186
|
1187
|
1188
|
1189
|
| ac |
ac |
ac |
ac |
tle |
ac |
ac |
ac |
ac |
ac |
1190
|
1191
|
1192
|
1193
|
1194
|
1195
|
1196
|
1197
|
1198
|
1199
|
| ac |
ac |
|
ac |
ac |
ac |
wa |
ac |
ac |
|
1200
|
1201
|
1202
|
1203
|
1204
|
1205
|
1206
|
1207
|
1208
|
1209
|
| ac |
ac |
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
状态更新:2008-7-13
posted @
2008-06-25 22:44 Fancy Mouse的Blog 阅读(556) |
评论 (1) |
编辑
Lairsoft 3月新作,题材很囧,人物很囧,战斗系统更囧。。。
剧情方面可以说亮点不多,但neta十分的严重,集中体现在有多处robo系anime的neta(有兴趣的话可以自己找找)。所谓的H,也退化为了封印恶仙人的办法(某种程度上说和补魔有异曲同工之妙……俄不是妙,是渣)。。。当然,剧情里主人公(改造仙人)和那只猫(该说开明兽)之间的对话可是非常的欢乐……非常非常的欢乐……
关于战斗系统,我想提几点trick
1.一定要勤用束缚丝。这玩意极其管用。而且最好放在右手的位置上。原因和下一条有关。
2.尽量5个格子分配5个不同的系,而且尽量在满足前一条的条件下,多储备五行珠,直到每个都储备满至少3个。这时启动右手束缚丝,5招combo,额外附加隐藏招黑龙扫叶腿,伤害虽然不是特别大,但是敌人物中毒+麻痹(行动力-10),5格子中毒。看出来多少实用了吧?那个麻痹可是能给你争取到很多主动的哦。
另:据偶研究,隐藏招发出的充要条件是5属性5combo。敌方不一定满足这个条件。
3.死掉以后不要Load,继续。继续以后你的行动力会额外多5,而且这可以累加。
4.选择宝物的时候,以行动力为至上准则。
毕竟最终战混沌loli不是那么好打的。混沌loli是25行动,600hp,3条线里最难的日和子线的话两个都不如她,hp连1/3都不到。要想这样战赢,至少要有足够的rp使得能够在前若干回合放出2次隐藏招,其中一次黑龙扫叶腿让混沌loli麻痹,那样胜算就大了。
以下是攻略:(转自http://bbs.game.kuaiche.com/viewthread.php?tid=54454&extra=page%3D1)
★戦闘
触ってみた。
答えられる範囲で答える。
★戦闘
三話
断るだろ。常識的に考えて。
【SAVE1】
その前にアイリーンを助けよう。
★戦闘
五話
アイリーンの身を案じる。
★戦闘
六話
出たとこ勝負でドーンといこう!
いいって、いいって!
【SAVE2】
やめておく。
BAD END
SAVE2开始
六話
頼む。
★戦闘
最終話
★戦闘
★戦闘
★戦闘
アイリーン END
SAVE1开始
三話
タマの言う通りに変身する
★戦闘
五話
【SAVE3】
真っ先にヘレーネの様子を見に行った。
★戦闘
六話
【SAVE4】
どうしたらいいかわからない。
BAD END
SAVE4开始
六話
辻にナチのアジトの場所を吐かせる。
★戦闘
最終話
★戦闘
★戦闘
★戦闘
ヘレーネ END
SAVE3开始
五話
真っ先に日和子の様子を見に行った。
★戦闘
六話
★戦闘
最終話
【SAVE5】
そのまま行かせる。
構わない。
BAD END
SAVE5开始
最終話
止める。
★戦闘
★戦闘
★戦闘
日和子 END
posted @
2008-06-25 22:04 Fancy Mouse的Blog 阅读(139) |
评论 (5) |
编辑
Exercises
15.5-4 Knuth has shown that there are always roots of optimal subtrees such that root[i,j-1]<=root[i,j]<=root[i+1,j] for all 1<=i
<=n. Use this fact to modify the OPTIMAL-BST procedure to run in Θ(n^2) time.
First prove this fact. Consider the optimal BST T[i+1,j] which has nodes from i+1 to j. Inserting a i node to T(i.e. i as i+1's left child, and proper adjustment to dummy nodes) makes also a legal BST T'[i,j]. If i+1's height is h, adding a i node leads to an increase of search cost by (h+1)*p[i]+(h+2)*q[i-1]+q[i].
When constructing the optimal BST T[i,j], if root[i,j] > root[i+1,j], then root[i+1,j](in T[i,j]) must appear in the root[i,j]'s left subtree. Since i+1's depth, with respective to root[i+1,j] in T[i,j] is identical to that in T[i+1,j]. The actual i's depth, i.e. with respective to T[i,j]'s root, root[i,j], is thus larger.
But, we have another optimal tree T[i,j], which as a less increasing cost when inserting node i. Thus, T[i+1,j] plus node i-1 can make a better tree, which contradicts T[i,j]'s optimism. Therefore, root[i,j]<=root[i+1,j].
Similarly, root[i,j-1]<=root[i,j].
Thus, we can modify the formula to e[i,j] = min{root[i,j-1]<=r<=root[i+1,j],e[i,r-1]+e[r+1,j]+w(i,j)}. Then we're to prove that the calculating of this formula, using dynamic programming, takes Θ(n^2) time.
we call the group of states e[i,j] with the fixed j-i (=k) the level-k group(obviously there're n-k nodes in the group). the calculation of e[i,j] takes root[i+1,j]-root[i,j-1]+1 iterations. thus, for all level-k group states, their calculations takes root[k,1]-root[1,k]+n-k iterations in all. Since 1<=root[k,1],root[1,k]<=n, the number of iterations is thus Θ(n). And the k varies from 0 to n-1. Thus the overall complexity is Θ(n)*n = Θ(n^2). This is a common trick to optimize a Θ(n^3) dp algorithm for some kind of problems into a Θ(n^2) one.
Problems
This section of this chapter contains many classic DP problems, including bitonic travelling problem(15-1), string edit distance(15-3), maximizing the sum of costs when non-adjacent nodes are selected in a tree(15-4), a job scheduling problem with deadlines(15-7). Other problems(15-2,15-5,15-6) are also good DP problems, but they are not difficult for OIers, are they?
posted @
2008-04-29 17:28 Fancy Mouse的Blog 阅读(284) |
评论 (1) |
编辑
Exercises
14.2-2 Can the black-heights of nodes in a red-black tree be maintained as fields in the nodes of the tree without affecting the asymptotic performance of any of the red-black tree operations? Show how, or argue why not.
The answer is yes. Red-black trees has two primitive operation. One is change a node's color and the other is rotations. Changing color only effects the node and its ancestors, which is O(logn) nodes. When rotating is performed, the nodes involved in rotating may have their b-h value changed, and so do their ancestors, which is also O(logn) nodes in all. Thus, maintaining this field results in an extra cost of O(logn) per operation, which does not affect the asymptotic performance of any rb-tree operation.
14.2-3 Can the depths of nodes in a red-black tree be efficiently maintained as fields in the nodes of the tree? Show how, or argue why not.
The answer is yes if an additional field, maintain, is maintained.
14.2-5 We wish to augment red-black trees with an operation RB-ENUMERATE(x,a,b) that outputs all the keys k such that a<=k<=b in a red-black tree rooted at x. Describe how RB-ENUMERATE can be implemented in Θ(m+logn) time, where m is the number of keys that are output and n is the number of internal nodes in the tree.(Hint: There is no need to add new fields to the red-black tree).
First, locate the smallest node which is not smaller than a. This takes Θ(logn). Then we're to prove that m-1 successive calls of SUCCESSOR operation takes Θ(m) time.
Consider the spanning tree T that connects these m nodes. Recall that these m nodes are successive. Thus if we draw the route the SUCCESSOR operations passes, each edge in T must be visited at least once and at most twice. Thus, the time for SUCCESSOR operations is Θ(m).
14.3-6 Show how to maintain a dynamic set Q of numbers that supports the operation MIN-GAP, which gives the magnitude of the difference of the two closest numbers in Q. Make the operations INSERT, DELETE, and MIN-GAP as efficient as possible, and analyze their running times.
Use any balanced binary search tree to store Q, and maintain another tree T. When a number x is inserted, consider x's predecessor y and successor z. Insert x-y and z-x into T(if exists). When a number x is deleted, also delete such x-y and z-x from T(if exists). The MIN-GAP call can be simply implemented by calling T's MINIMUM operation. Thus, all operations can be performed in Θ(logn).
posted @
2008-04-29 17:17 Fancy Mouse的Blog 阅读(99) |
评论 (0) |
编辑
We use the following expression S(T) to show a tree T:
if T is null, then S(T) is a null string
if T contains only a root node, S(T) = root
otherwise, let L and R are T's left and right subtrees, respectively, S(T) = root(S(L),S(R))
Exercises
13.1-7 Describe a red-black tree on n keys that realizes the largest possible ratio of red internal nodes to black internal nodes. What is the ratio? What tree has the smallest possible ratio, and what is the ratio?
Largest: Tree: 2(1,3), when 1,3 are red. The ratio is 2.
Smallest: a tree with only a root node. The ratio is 0.
13.2-5 We say that a binary search tree T1 can be right-converted to binary search tree T2 if it is possible to obtain T2 from T1 via a series of calls to RIGHT-ROTATE. Give an example of two trees T1 and T2 such that T1 cannot be right-converted to T2. Then show that if a tree T1 can be right-converted to T2, it can be right-converted using O(n^2) calls to RIGHT-ROTATE
The counter-example is : T1: 1(,2), T2: 2(1,). Or, a simple case that T2 can be right-converted to T1. It can be proved that when T2 can be right-converted to T1, T1 is not so to T2.
The O(n^2) proof is also not difficult. If T1's root is different from T2's, O(n) RIGHT-ROTATEs are needed to turn T1's root to T2's. Then, think of the right subtrees of T1's and T2's. We can conclude a recurrence of T(n) = T(n-1) + O(n), thus T(n) = O(n^2)
13.4-7 Suppose that a node x is inserted into a red-black tree with RB-INSERT and then immediately deleted with RB-DELETE. Is the resulting red-black tree the same as the initial red-black tree? Justify your answer.
The answer is no. Consider the tree T = 2(1,3), where 1 and 3 are the two red nodes. When we insert 1.5, which is initially inserted as 1's right node, 1 and 3 nodes will turn black, and 1.5 will be red. Deleting 1.5 node doesn't effect on other nodes. Thus, after inserting and deleting 1.5, the 1 and 3 nodes will turn black.
Another example is the Figure 13.4 on the book. The procedure of inserting 4 is shown on Figure 13.4, and deleting 4 also has no effect on other nodes. The resulting tree is also different from Figure 13.4(a).
posted @
2008-04-22 01:01 Fancy Mouse的Blog 阅读(121) |
评论 (0) |
编辑
提醒自己用
1.gvim英文字体错乱
/etc/vim/gvimrc
去掉一下几行的注释:
if has('gui_gtk2')
set guifont=Monospace\ 9
else
set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
endif
2.compiz以后标题栏消失
重启Windows Decoration组件
3.scim无法输入文字
/etc/X11/xinit/xinput.d/all_ALL
对应域改成:
GTK_IM_MODULE=scim
QT_IM_MODULE=scim
zh_CN文件也如此修改
顺便一说,scim的输入法个人推荐:中文,智能拼音;日文,Anthy。以上足够。
4.firefox等里中文字体一致性问题
将Edit->Preference->Content->[Fonts&Colors]Advanced里,对每一种相关的语言都设置同一种Serif和Sans-serif字体。
5.mplayer的绝大多数video output不能正常处理宽屏下的宽高比
/etc/mplayer/mplayer.conf或~/.mplayer/config
修改monitoraspect域到正确的值
-----------
换用smplayer可以完美解决这问题(它能够自动判定宽高比)
这个是个人推荐的mplayer的gui前端。注意渲染器选x11即可。
6.启动alsa软混音
/etc/asound.conf(可能需要创建该文件)
pcm.card0
{
type hw
card 0
}
pcm.!default
{
type plug
slave.pcm "dmixer"
}
pcm.dmixer
{
type dmix
ipc_key 1024
slave
{
pcm "hw:0,0"
period_time 0
period_size 1024
buffer_size 4096
periods 128
rate 44100
}
bindings
{
0 0
1 1
}
}
rate可以设为48000,但在混44100采样的音时会有爆音现象,所以不推荐。
7.什么程序都没启动,cpu满占用,或者iowait满占用
一般问题出在index服务中。关闭index preferences里的enable indexing和enable watching,然后kill掉trackerd进程。我个人的结论是,满cpu占用产生于trackerd的index过程,而iowait满占用则来自于trackerd的大内存占用导致的频繁内存换页(在我发生问题的时候trackerd占了70%+的physical memory)
8.gvim中F9单键编译+运行
以g++为例子
~/.vimrc里添加:
map <F9> :call CompileAndRun()<CR>
func! CompileAndRun()
exec "!g++ % -o %<"
exec "!./%<"
end func
在这里可以推导出来%和%<的变量意义(之前偶因为不知道linux必须要./xxx才能调用当前目录的可执行文件,结果郁闷了半天- -|||)
附:ACM用gvim+clewn推荐vimrc配置:
map <C-F9> :call Compile()<CR>
func! Compile()
exec "w"
exec "!g++ % -g -o %<.o"
endfunc
map <F9> :call CompileAndRun()<CR>
func! CompileAndRun()
call Compile()
exec "nbkey S-R"
endfunc
map <C-F12> i#include<iostream><CR>using namespace std;<CR><CR>int main()<CR>{<CR>return 0;<CR>}<CR><Esc>kkko
map <C-A> ggVG
map <C-C> "+y
map <C-F11> ggVG"+y
map <C-V> "+p
ab #d #define
ab #i #include
9.键盘使用异常,e.g."号要打2次才出来,中文输入法里打不出引号等
将System->Preferences->Keyboard->Layouts里把U.S. English Intl改成U.S.English default
10.某些窗口会发生标题栏没有关闭钮(但是鼠标还是能点)的现象
System->Preferences->Emerald Theme Manager->Emerald Settings,去除Use Button Fade的勾
posted @
2008-03-04 12:03 Fancy Mouse的Blog 阅读(268) |
评论 (1) |
编辑
Exercises
12.1-3 Give a nonrecursive algorithm that performs an inorder tree walk.
Here I give a solution that uses no stack but assumes that two pointers can be tested for equality.
InorderTraverse(T)

...{
Node *p = T.root, *q = T.root;
while(p->left != NIL) p = p->left; //p is now the first node to be visited
while(q->right != NIL) q = q->right; //q is the last
while(p != q)

...{
p->Print;
p = p->parent;
if(p->right != NIL)

...{
p = p->right;
while(p->left != NIL) p = p->left;
}
}
q->Print;
}
This does not seem to be elegant, but it does perform a inorder tree walk in Θ(n) time, because any tree edge is visited twice and there're n-1 edges in an n-node tree in all.
Note that the structure of the traverse can also be applied to ex 12.2-7
12.3-5 Is the operation of deletion "commutative" in the sense that deleting x and then y from a binary search tree leaves the same tree as deleting y and then x? Argue why it is or give a counterexample.
Deletion is commutative for a ordinary binary search tree. We'll simply observe the situation when TREE-DELETE may pick the predecessor of a node.
Recall that the deletion operation only requires the change of the node itself, and additionally the node's predecessor (if necessary). So if x is not y's predecessor and vice versa, the two operations are independent and the different deletion order won't make a different tree.
If x is y's predecessor, then x is a leaf node. Deleting x is simple, and deleting y will replace y with x's parent. If y is deleted first, x will replace y. Then the deletion of x afterwards will substitute x's new predecessor (which is also x's original parent) for x. This leads to the identical tree.
Problems
12.3 Average node depth in a randomly built binary search tree
f. Describe an implementation of quicksort in which the comparisons to sort a set of elements are exactly the same as the comparisons to insert the elements into a binary search tree. (The order in which comparisons are made may differ, but the same comparisons must be made.)
Any quicksort whose partition is based on the comparison between the candidate and the pivot satisfies the requirement. The pivot is the root of the subtree, and the comparison between the candidate and the pivot is equivalent to the process that the candidate goes down the root (left or right).
And of course, an optimization of using insertion sort in a small scale input is not allowed.
posted @
2008-02-16 11:27 Fancy Mouse的Blog 阅读(180) |
评论 (0) |
编辑