hiho week 66 register

Ended

Participants:488

Verdict:Accepted
Score:100 / 100
Submitted:2015-10-04 18:41:20

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 <queue>
#include <climits>
using namespace std;
const int MAXN = 100;
char board[MAXN][MAXN];
int dist[MAXN][MAXN];
int m, n, hi, hj, min_dist = INT_MAX;
void check(int i, int j, int nd, bool isS, queue<pair<int, int>>& q) {
    if (i < 0 || i >= n || j < 0 || j >= m) return;
    if (board[i][j] == 'P' || board[i][j] == '#') return;
    if (isS && board[i][j] == 'S') {
        if (dist[i][j] != INT_MAX) {
            min_dist = min(min_dist, dist[i][j] + nd);
        }
    } else if (!isS){
        if (dist[i][j] == INT_MAX) {
            dist[i][j] = nd + 1;
            q.push({i, j});
        }
    }
}
void bfs() {
    queue<pair<int, int>> q;
    dist[hi][hj] = 0;
    q.push({hi, hj});
    
    while (!q.empty()) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX