Language: C++

// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 088 _ d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int H, W;
// Board[H][W];
string B[50];
int vx[] = {1,-1,0,0};
int vy[] = {0,0,1,-1};

vector<vector<int>> memo(50,vector<int>(50,0));
bool state[50][50] = {false};

int solve()
{
  // queueXとqueueYのpair
  queue<pair<int,int>> q;
  q.push({0,0});
  state[0][0] = true;
  //memo[0][0] = 0;
  
  while (!q.empty()) {
    auto tmp = q.front();
    q.pop();
    int x,y;
    tie(x,y) = q;
    if (x == W-1 && y == H-1) return memo[y][x];
    REP(i,4) {
      int nextX = x + vx[i];
      int nextY = y + vy[i];
      
      if (0 <= nextX && nextX < W
      &&  0 <= nextY && nextY < H
      //&& memo[nextY][nextX] == -1
      &&  state[nextY][nextX] == false
      &&  B[nextY][nextX] == '.') {
        state[nextY][nextX] = true;
        memo[nextY][nextX] = memo[y][x] + 1;
        q.push({nextX,nextY});
      }
    }
  }
  return 0;
}


int main()
{
  int cnt = 0;
  cin >> H >> W;
  REP(hi,H) {
    cin >> B[hi];
    REP(si,B[hi].size()) if (B[hi][si] == '#') ++cnt;
  }
  
  int ans, res = solve();
  if (res == 0) {
    ans = -1;
  } else {
    //ans = H*W - (#の数) - (すぬけ君が通るマスの数);
    ans = H*W - cnt - res - 1;
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:38:16: error: no match for 'operator=' (operand types are 'std::tuple<int&, int&>' and 'std::queue<std::pair<int, int> >')
   38 |     tie(x,y) = q;
      |                ^
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:7:
/usr/include/c++/14/tuple:2355:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<const _U1&, const _U2&>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::tuple<_U1, _U2>&) [with _U2 = _U1; _T1 = int&; _T2 = int&]'
 2355 |         operator=(const tuple<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2355:9: note:   template argument deduction/substitution failed:
a.cc:38:16: note:   'std::queue<std::pair<int, int> >' is not derived from 'const std::tuple<_T1, _T2>'
   38 |     tie(x,y) = q;
      |                ^
/usr/include/c++/14/tuple:2365:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<_U1, _U2>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::tuple<_U1, _U2>&&) [with _U2 = _U1; _T1 = int&; _T2 = int&]'
 2365 |         operator=(tuple<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2365:9: note:   template argument deduction/substitution failed:
a.cc:38:16: note:   'std::queue<std::pair<int, int> >' is not derived from 'std::tuple<_T1, _T2>'
   38 |     tie(x,y) = q;
      |                ^
/usr/include/c++/14/tuple:2375:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<const _U1&, const _U2&>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(const std::pair<_U1, _U2>&) [with _U2 = _U1; _T1 = int&; _T2 = int&]'
 2375 |         operator=(const pair<_U1, _U2>& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2375:9: note:   template argument deduction/substitution failed:
a.cc:38:16: note:   'std::queue<std::pair<int, int> >' is not derived from 'const std::pair<_T1, _T2>'
   38 |     tie(x,y) = q;
      |                ^
/usr/include/c++/14/tuple:2386:9: note: candidate: 'template<class _U1, class _U2> std::__enable_if_t<((bool)__assignable<_U1, _U2>()), std::tuple<_T1, _T2>&> std::tuple<_T1, _T2>::operator=(std::pair<_U1, _U2>&&) [with _U2 = _U1; _T1 = int&; _T2 = int&]'
 2386 |         operator=(pair<_U1, _U2>&& __in)
      |         ^~~~~~~~
/usr/include/c++/14/tuple:2386:9: note:   template argument deduction/substitution failed:
a.cc:38:16: note:   'std::queue<std::pair<int, int> >' is not derived from 'std::pair<_T1, _T2>'
   38 |     tie(x,y) = q;
      |                ^
/usr/include/c++/14/tuple:2332:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::__conditional_t<((bool)__assignable<const _T1&, const _T2&>()), const std::tuple<_T1, _T2>&, const std::__nonesuch&>) [with _T1 = int&; _T2 = int&; std::__conditional_t<((bool)__assignable<const _T1&, const _T2&>()), const std::tuple<_T1, _T2>&, const std::__nonesuch&> = const std::tuple<int&, int&>&]'
 2332 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:2334:52: note:   no known conversion for argument 1 from 'std::queue<std::pair<int, int> >' to 'std::__conditional_t<true, const std::tuple<int&, int&>&, const std::__nonesuch&>' {aka 'const std::tuple<int&, int&>&'}
 2332 |       operator=(__conditional_t<__assignable<const _T1&, const _T2&>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2333 |                                 const tuple&,
      |                                 ~~~~~~~~~~~~~       
 2334 |                                 const __nonesuch&> __in)
      |                                 ~~~~~~~~~~~~~~~~~~~^~~~
/usr/include/c++/14/tuple:2343:7: note: candidate: 'std::tuple<_T1, _T2>& std::tuple<_T1, _T2>::operator=(std::__conditional_t<((bool)__assignable<_T1, _T2>()), std::tuple<_T1, _T2>&&, std::__nonesuch&&>) [with _T1 = int&; _T2 = int&; std::__conditional_t<((bool)__assignable<_T1, _T2>()), std::tuple<_T1, _T2>&&, std::__nonesuch&&> = std::tuple<int&, int&>&&]'
 2343 |       operator=(__conditional_t<__assignable<_T1, _T2>(),
      |       ^~~~~~~~
/usr/include/c++/14/tuple:2345:47: note:   no known conversion for argument 1 from 'std::queue<std::pair<int, int> >' to 'std::__conditional_t<true, std::tuple<int&, int&>&&, std::__nonesuch&&>' {aka 'std::tuple<int&, int&>&&'}
 2343 |       operator=(__conditional_t<__assignable<_T1, _T2>(),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2344 |                                 tuple&&,
      |                                 ~~~~~~~~       
 2345 |                                 __nonesuch&&> __in)
      |                                 ~~~~~~~~~~~~~~^~~~