2012年10月13日
摘要: CODE:#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>usingnamespacestd;charstr[10]="HDU";intmain(){intn;intT;scanf("%d",&T);while(T--){scanf("%d",&n);for(inti=0;i<3*n;i++){for(intj=0;j<n;j++){printf("%s" 阅读全文
posted @ 2012-10-13 22:13 有间博客 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 大意:给你一些定点,让你以代价最小的边将所有的点连起来。思路:数据范围很小,可以通过最小生成树或者回溯来解决。最小生成树去写时不知道哪错了,于是用回溯模拟了一遍,相当于模拟一个数组的全排列。AC CODE:#include<cstdio>#include<cstdlib>#include<cstring>#include<cmath>#include<climits>//INT_MAX,整形范围内的最大整数。#include<algorithm>usingnamespacestd;#defineINF0x3f3f3f3fc 阅读全文
posted @ 2012-10-13 18:41 有间博客 阅读(551) 评论(1) 推荐(0) 编辑
摘要: 大意;求在最小的交换次数的情况下使得序列升序排列的方案数。思路:冒泡排序对应最小交换数,然后回溯。CODE:#include<iostream>#include<cstdlib>#include<cstdio>#include<cstring>usingnamespacestd;intans;intn;inta[1001];intcheck(int*a){for(inti=0;i<n-1;i++){if(a[i]>a[i+1])return0;}return1;}voidswap(int&a,int&b){intt=a 阅读全文
posted @ 2012-10-13 12:40 有间博客 阅读(185) 评论(0) 推荐(0) 编辑
摘要: BFS+hash判重。CODE:(TLE)#include<iostream>#include<cstdlib>#include<cstdio>#include<cstring>#include<queue>#include<set>usingnamespacestd;typedefintState[9];constintMAXN=1000003;constintdx[]={-1,1,0,0};constintdy[]={0,0,-1,1};chardir[5]="udlr";intgoal[9]={1 阅读全文
posted @ 2012-10-13 09:50 有间博客 阅读(407) 评论(0) 推荐(0) 编辑