摘要:
大意;求在最小的交换次数的情况下使得序列升序排列的方案数。思路:冒泡排序对应最小交换数,然后回溯。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 阅读全文
摘要:
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 阅读全文