SRM 563 Div2 Medium(550) CoinsGameEasy

幅優先でゲームが終わったかどうかをチェック.
今まで通ったセルを記録しておきもし通っていたら,それ以降は探索しない(幅優先なのでその状態までの最短パスが既にもとまっている).
最初通ったセルの記憶をmap, bool>で持っていたがmp.find(make_pair(p1, p2))でエラーになってた.posとposの比較ができないから?

class CoinsGameEasy {
public:
  // int dy[4] = {-1, 0, 1, 0};
  class pos{
  public:
    int x1, y1, step, x2, y2;
    pos(int x_, int y_, int x2_, int y2_, int step_){
      x1 = x_;
      y1 = y_;
      x2 = x2_;
      y2 = y2_;
      step = step_;
    }
  };

  int minimalSteps(vector <string> board) {
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    vector<string> b = board;
    int n = board.size();
    int m = board[0].size();
    int i,j;
    int x1, y1, x2, y2;
    vector<pos> st;
    map<pair<pair<int, int>, pair<int, int> >, bool> mp;
    x1 = y1 = x2 = y2= -1;
    for(i = 0; i < n; i++){
      for(j = 0; j < m; j++){
        if(b[i][j] == 'o'){
          if(x1 == -1){
            x1 = j;
            y1 = i;
          }else{
            x2 = j;
            y2 = i;
          }
          b[i][j] = '.';
        }
      }
    }
    st.push_back(pos(x1, y1, x2, y2, 0));
    mp[pair<pair<int, int>, pair<int, int> >(make_pair<int, int>(x1, y1), make_pair<int, int>(x2, y2))] = true;
    while(st.size() > 0){
      const pos p = st[0];
      st.erase(st.begin());
      if (p.step >= 10) return -1;
      for(i = 0; i < 4; i++){
        int nx1, ny1, nx2, ny2;
        nx1 = p.x1 + dx[i];
        nx2 = p.x2 + dx[i];
        ny1 = p.y1 + dy[i];
        ny2 = p.y2 + dy[i];
        // finish?
        bool fall1 = false;
        bool fall2 = false;
        if(nx1 < 0 || nx1 >= m || ny1 < 0 || ny1 >= n) fall1 = true;
        if(nx2 < 0 || nx2 >= m || ny2 < 0 || ny2 >= n) fall2 = true;
        if(fall1 && fall2) continue;
        if(fall1 || fall2) return p.step+1;

        if(b[ny1][nx1] == '#'){
          ny1 = p.y1; nx1 = p.x1;
        }
        if(b[ny2][nx2] == '#'){
          ny2 = p.y2; nx2 = p.x2;
        }
        pair<pair<int, int>, pair<int, int> > key(make_pair<int, int>(nx1, ny1), make_pair<int, int>(nx2, ny2));
        if (mp.find(key) == mp.end()){
          pos np(nx1, ny1, nx2, ny2, p.step+1);
          st.push_back(np);
          mp[key] = true;
        }
      }
    }
    return -1;
  }
};