hiho week 99 register

Ended

Participants:253

Verdict:Accepted
Score:100 / 100
Submitted:2016-05-27 16:14:14

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<stdio.h>
#include<iostream>
using namespace std;
int state[3][9][9];
int way[8][2]={{2,-1},{2,1},{-2,-1},{-2,1},{1,-2},{1,2},{-1,-2},{-1,2}};
int que[100][2];
void bfs(int * f ,int x,int y,int statei[9][9]){
    int first=0, last=0;
    int visit[9][9]={0};
    que[0][0]=f[0];
    que[0][1]=f[1];
    last++;
      statei[f[0]][f[1]]=0;
      visit[f[0]][f[1]]=0;
      if(statei[x][y]>=0)
        return ;
    while(first<last){
        int a=que[first][0] , b=que[first][1] ,c,d,finded=0;
        first++;
        for(int i=0; i< 8;i++){
            c=a+way[i][0];
            d=b+way[i][1];
            if(c>=0&&c<8&&d>=0&&d<8&&visit[c][d]==0){
                    visit[c][d]=1;
            if(statei[c][d]<0){
                statei[c][d] = statei[a][b]+1;
            }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX