神之码
百度空间 | 百度首页 
 
文章列表
 
2006年10月30日 星期一 21:27

 

 
2006年07月20日 星期四 01:58
#include  
#include  
#include  

using namespace std;

struct map
{
 int Gap;
 int Board[9];
};

const int max_len = 20000;
const int hash_size = 59999;

int SLen, DLen, SCursor, DCursor, SStep, DStep;
int SQ[max_len], DQ[max_len];
char SGaps[max_len], DGaps[max_len];
char Hash[hash_size];
int HashKeys[hash_size];
map SMap, DMap;
int SKey, DKey;

inline char& hash(int V)
{
 int Key = V * 4 % hash_size;
 V++;
 while (HashKeys[Key] != 0 && HashKeys[Key] != V)
 {
  Key++;
  if (Key == hash_size) Key = 0;
 }
 HashKeys[Key] = V;
 return Hash[Key];
}

inline int convert(int P[])
{
 int I;
 int Key = 0;
 for (I = 8; I >= 0; I--)
  if (P[I] != 0)
  {
   Key <<= 3;
   Key |= P[I] - 1;
  }
 return Key;
}

bool search(int& FCursor, int& FLen, int Q[], char Gaps[], int Dir)
{
 int Cursor = FCursor;
 int Len = FLen;
 int Limit = Len;
 while (Cursor < Limit)
 {
  int Key = Q[Cursor];
  char Gap = Gaps[Cursor];
  int Delta = Gap + Gap + Gap;
  if (Gap < 6)
  {
   int Key2 = Key
 
2006年07月20日 星期四 01:57
#include <stdio.h>
#include <string.h>
struct Node {
char d[9];
char p;
};
int p11,p12,p21,p22;
int step1,step2;
Node q1[181500],q2[181500];
Node start,target;
char flag[362880]={0};
int v_target,v_start;
int ans;
int power[]={1,1,2,6,24,120,720,5040,40320};
int movpn[9]={2,3,2,3,4,3,2,3,2};
int movp[9][4]={{1,3},{2,0,4},{5,1},{4,0,6},{5,1,3,7},{8,2,4},{7,3},{8,4,6},{5,7}};
void readdata(Node &p)
{
int x;
for(int i=0;i<9;i++) {
scanf("%d",&x);
p.d[i]=x;
if(x==0) p.p=i;
}
}
void read()
{
freopen("start.txt","r",stdin);
readdata(start);
fclose(stdin);
freopen("goal.txt","r",stdin);
readdata(target);
fclose(stdin);
}
int hash(Node &p)
{
int ret=0;
int i,j;
for(i=1;i<9;i++)
for(j=0;j<i;j++) if(p.d[i]>p.d[j]) ret+=power[i];
r
 
2006年07月20日 星期四 01:55
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const int hashsize=70001;
const int maxnode=50000;
const int maxp=40;
const int ten[]={1,10,100,1000,10000,100000,1000000,10000000,100000000};
const int C[]={2,3,2,3,4,3,2,3,2};
const int EP[][4]={{1,3,0,0},{0,2,4,0},{1,5,0,0},{0,4,6,0},{1,3,5,7},{2,4,8,0},{3,7,0,0},{4,6,8,0},{5,7,0,0}};
struct Tlist
{
int data,d;
Tlist *next;
};
struct Thashpoint
{
int data;
Thashpoint *next;
};
//Memory
int ID;
Tlist listM[maxnode],*q;
Thashpoint hashM[maxnode],*p;
//data
int src,dest;
//heap
Tlist *head[maxp],*expand[maxp],*lp1,*lp2;
//Hash
Thashpoint *hash[hashsize];
//expand
int nowp,A[9],arcT[9],dist[9][9],b,depth,swap[9][9];
int data,G,newdata,newG;
bool find_answer;
void readdata(const char *filename,int &data)
{
int i,v;
FILE *
 
     
 
背景音乐
 
 
 
个人档案
 
dhy11100

上次登录:
2006年11月
加为好友
 
   
 
最新照片
 
   
 
订阅我的空间
 
已有人次访问本空间
 
订阅RSS  什么是RSS?

您也想拥有这样的空间?请点此申请。
     
 
最近访客
 
 

xiaoc10

icecho

懒人不行

faithyacht
     


©2009 Baidu