摘要: /*设原序列的逆序数为sum,每往后移一个数,可以找到规律sum += n-2*num[i]-1;(n为元素个数,num[i]为移动的数);求原序列的逆序数时可以用线段树,每输入一个数,先querry [输入的数,n]中元素的个数,再把num[i]插入到线段树中。。。*/#include <iostream>#include <cstdio>#include <cstring>#define L(x) x << 1#define R(x) x << 1 | 1using namespace std;const int N = 5005 阅读全文
posted @ 2011-09-14 21:25 AC_Von 阅读(161) 评论(0) 推荐(0) 编辑
摘要: /*贡献出无数WA, 就因为一个地方写错, 悲剧的一晚上啊!不过能过了还是很爽的。 思路:用Trie树给字符串重新标号,然后用并查集,用一个a[i] 记录当前并查集跟结点上连接的结点数。*/#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct node{ int flag; node * next[53];};const int N = 200005;int parent[N];int rank[N];int a[N];int num;node * n 阅读全文
posted @ 2011-09-14 00:25 AC_Von 阅读(216) 评论(0) 推荐(0) 编辑