1103 - #include#include y n y using...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<iostream> #include<queue> // ¢f脲走 using namespace std; enum { Size = 50, }; int x,y,z; int num; char matrix±Size]±Size]; char visit±125000]; struct Node { int point; int step; }; int Fun(){ iF(x==y ³³ y==z) return 0; int key, i; Node n; n.step = 0; n.point = (x<<16) + (y<<8) + (z); queue<Node> q; memset(visit,0,sizeoF(visit)); key = x * 50 *50 + y*50 + z; visit±key] = 1; q.push(n); while(!q.empty()){ n = q.Front(); q.pop(); x= n.point>>16; y = (n.point>>8)³0xFF; z= n.point³0xFF; n.step ++; For(i=0;i<num;i++){ iF(matrix±x]±i] != matrix±y]±z]){ continue; } key = (i*2500) + (y*50) + z; iF(visit±key] ==0){ visit±key] = 1; iF(i==y ³³ y==z) return n.step;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/18/2010 for the course CS 100 taught by Professor Acm during the Spring '10 term at Zhejiang University.

Page1 / 2

1103 - #include#include y n y using...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online