hiho week 166 register

Ended

Participants:289

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-06 18:37:29

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<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
int N, M, K, a, b, c, d;
string mp[105];
int key[5][2];
int direct[4][2] = { { 0, 1 }, { 1, 0 }, { -1, 0 }, { 0, -1 } };
int result = -1;
bool visited[105][105][32] = { 0 };
queue<vector<int>> q;
void insert(int x, int y, int step, int status)
{
    if (x<0 || x >= N || y<0 || y >= M || mp[x][y] == '#')return;
    if (mp[x][y] != '.'&&!(status&(1 << mp[x][y] - 'A')))return;
    if (x == c&&y == d){
        if (result == -1 || result>step)result = step;
        return;
    }
    if (visited[x][y][status])return;
    visited[x][y][status] = 1;
    for (int i = 0; i<K; i++){
        if (x == key[i][0] && y == key[i][1])status |= (1 << i);
    }
    visited[x][y][status] = 1;
    vector<int> ne(4);
    ne[0] = x;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX