随笔分类 -  CF

 
Codeforces Round #252 (Div. 2) D
摘要:http://codeforces.com/problemset/problem/441/D置换群的基本问题,一个轮换内交换成正常顺序需要k-1次,k为轮换内元素个数两个轮换之间交换元素,可以把两个轮换合并成1个,总交换次数+1一个轮换内部交换,可以把一个轮换拆分成两个,总交换次数-1#includ... 阅读全文
posted @ 2014-06-09 14:14 LegendaryAC 阅读(432) 评论(0) 推荐(0)
CF 432D
摘要:http://codeforces.com/problemset/problem/432/D在前缀是后缀的前提下,求这个前缀在原串中出现了多少次出现的次数可以用dp求解,前缀是后缀直接用Next判断,较为综合的kmp考察,这题没写出来就是kmp基础不牢,不应该#include #include #i... 阅读全文
posted @ 2014-05-20 20:14 LegendaryAC 阅读(321) 评论(0) 推荐(0)
CF 382C
摘要:http://codeforces.com/problemset/problem/382/C读完题立刻知道怎么做,然后分类讨论到吐血,写挂了,巨蠢#include #include #include #include using namespace std ;int n ;int a[100005] ;int temp1,temp2 ;int cnt1,cnt2,p1,p2 ;int gao(){ int f=1 ; cnt1=cnt2=0 ; temp1=a[0]-a[1] ; for(int i=1 ;i=1 ;i--) if(a[i]-a[i-1]!... 阅读全文
posted @ 2014-01-18 02:50 LegendaryAC 阅读(282) 评论(0) 推荐(0)
两个二分
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4190二分答案#include using namespace std ;int a[500005] ;int main(){ int n,b ; while(~scanf("%d%d",&n,&b),n!=-1) { int maxn=-1 ; for(int i=0 ;i>1 ; int sum=0 ; for(int i=0 ;ib) left=mid+1 ; e... 阅读全文
posted @ 2014-01-17 22:16 LegendaryAC 阅读(165) 评论(0) 推荐(0)
369C Valera and Elections
摘要:http://codeforces.com/problemset/problem/369/C树的遍历,dfs搜一下,从根节点搜到每个分叉末尾,记录一下路况,如果有需要修复的,就把分叉末尾的节点加入答案10w个点要用邻接表存图#include using namespace std ;typedef struct L{ int s,t ; int v ; int nxt ; }L ;L e[200005] ;int head[100005] ;int cnt ;void ins(int s,int t,int v){ e[cnt].t=t ; e[cnt].v=(v... 阅读全文
posted @ 2013-12-28 23:42 LegendaryAC 阅读(217) 评论(0) 推荐(0)