hiho week 99 register

Ended

Participants:253

Verdict:Accepted
Score:100 / 100
Submitted:2016-05-25 22:50:22

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
char start[3][3];
queue<int> q;
int step[270000];
int now_status;
int next_status;
int next_step[8][2] = { { -2,1 },{ -1,2 },{ 1,2 },{ 2,1 },{ 2,-1 },{ 1,-2 },{ -1,-2 },{ -2,-1 } };
int move(int status,int i, int j)
{
    int now_site = (status >> (6 * (2 - i))) & 0x3F;
    int now_x = now_site >> 3;
    int now_y = now_site & 0x7;
    int next_site = now_site;
    int next_x = now_x - next_step[j][1];
    int next_y = now_y + next_step[j][0];
    if ((next_x >= 0 && next_x <= 7) && (next_y >= 0 && next_y <= 7))
    {
        next_site += next_step[j][0] - 8 * next_step[j][1];
        next_status = status - (now_site << (6 * (2 - i))) + (next_site << (6 * (2 - i)));
    }
    else
        return -1;
    return next_status;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX