摘要: http://codeforces.com/problemset/problem/330/B题解: 关键在于 m #include#includeusing namespace std;int map[1005];int main(){ // freopen("1.txt","r",stdin); int n,m,a,b; while(~scanf("%d %d",&n,&m)) { int ans=1; memset(map,0,sizeof(map)); for(int i=0; i<m; i++) { .. 阅读全文
posted @ 2013-07-21 10:26 JKXQJ 阅读(243) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/330/A#include#include#includeusing namespace std;int row[10][10],col[10][10];char s[10][10];int main(){ // freopen("1.txt","r",stdin); int r,c; while(scanf("%d%d",&r,&c)!=EOF) { memset(row,0,sizeof(row)); memset(col,0,siz 阅读全文
posted @ 2013-07-21 09:39 JKXQJ 阅读(280) 评论(0) 推荐(0) 编辑
摘要: hdu 1394http://acm.hdu.edu.cn/showproblem.php?pid=1394用线段树求逆序数,例如要求x的逆序数只需要访问(x+1,n)段有多少个数,就是x的逆序数。还有就是求最小逆序数的时候有个巧妙的想法,当把x放入数组的后面,此时的逆序数应该为x没放入最后面之前的逆序总数加上(n-x)再减去(x-1);sum = sum+(n-x[i])-(x[i]-1)。线段树#include#include#includeusing namespace std;#define lson l , m , rt > 1; build(lson); build(r... 阅读全文
posted @ 2013-07-21 01:58 JKXQJ 阅读(363) 评论(0) 推荐(0) 编辑