2012年8月26日

ZOJ Monthly, August 2012 3643 Keep Deleting

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3643题意:给出A串和B串,删除B串中的A串。思路:栈+暴力,strcmp函数比较的时候,如果不相等就会马上退出,这样最坏的时间复杂度是O(maxn/256*(1+256)*256/2)。ps:不知道官方解题是怎么样弄的。View Code #include<stdio.h>#include<string.h>#define maxn 512005char as[maxn],bs[2000],st[maxn];int ans,tp;int main 阅读全文

posted @ 2012-08-26 21:41 aigoruan 阅读(196) 评论(0) 推荐(0)

ZOJ Monthly, August 2012 3641 Information Sharing

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3641题意:有三种操作:1)arriveNamema1a2..am:名字为Name的人到达,带有m个信息:a1a2..am(m<=10)2)shareName1Name2:Name1和Name2共享信息(注意是一直共享的)3)checkName:检查Name拥有的信息,并要求输出。信息最多1000个,现有n个这些操作。思路:并差集,将共享信息的人弄成一个连通分量,并合并信息。View Code #include<stdio.h>#include<s 阅读全文

posted @ 2012-08-26 21:38 aigoruan 阅读(191) 评论(0) 推荐(0)

ZOJ Monthly, August 2012 3635 Cinema in Akiba

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3635题意:先给一个数列1、2、3……n。然后求第k小,并将它删除。思路:树状数组+二分 模板View Code #include<stdio.h>#include<string.h>#include<iostream>#define lowbit(x) (x)&(-x)using namespace std;const int maxn = 100005;int n,sum[1<<20];int as[maxn]; 阅读全文

posted @ 2012-08-26 21:36 aigoruan 阅读(210) 评论(0) 推荐(0)

ZOJ Monthly, August 2012 3633 Alice's present

摘要: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3633题意:给一个数列,每次询问一个区间第一次出现两次的位置(从右向左)。思路:开一个数组,记录当前值的左边第一次出现的位置。然后用线段树维护这个数组的区间最大值就行了。View Code #include<stdio.h>#include<string.h>#include<map>#include<utility>#include<algorithm>using namespace std;const int 阅读全文

posted @ 2012-08-26 21:32 aigoruan 阅读(208) 评论(0) 推荐(0)

uva 10275 Guess the Number!

摘要: Guess the Number!http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1216题意:给一个大数,问能否写成n^n。如果能,输出n,否则输出-1。思路:除了1^1=1,2^2=4特殊外,其它数n^n所得到的数具有唯一的位数。这样可通过所给的大数的位数确定是哪个数,然后求n^n和所给的大数比较就行了。n^n用快速幂来弄,然后用傅立叶大数相乘模板卡过去了,这个方法可能不是正解。View Code #include<st 阅读全文

posted @ 2012-08-26 20:51 aigoruan 阅读(242) 评论(0) 推荐(0)

导航