Language: Java

#include <iostream>
#include <vector>
#include <string.h>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <cmath>
#include <map>
#include <set>
#include <assert.h>
#define REP(i,n) for(ll i=0;i<(n);i++)
#define MOD 1000000007
//#define int long long
#ifdef int
const long long INF = LLONG_MAX / 10;
#else
const int INF = 1010101010;
#endif
using namespace std;
typedef long long ll;
typedef vector<vector<ll> > mat;
typedef pair<int, int> P;
//typedef pair<double, double> P;
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};

int H, W;
char maze[60][60];
int sx, sy;
int gx, gy;
int d[60][60];  //各点までの最短距離の配列

//(sx, sy)から(gx, gy)への最短経路を求める
int bfs()
{
  queue<P> que;
  REP(i,H) REP(j,W) d[i][j] = INF;
  que.push(P(sx, sy));
  d[sy][sx] = 0;

  while (que.size()) {
    P p = que.front(); que.pop();
    if (p.first == gx && p.second == gy) break;
    REP(i,4) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (0 <= nx && nx < W && 0 <= ny && ny < H && maze[ny][nx] != '#' && d[ny][nx] == INF) {
        que.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }

  return d[gy][gx];
}

signed main()
{
  cin >> H >> W;
  int x = 0;
  REP(i,H) REP(j,W) {
    cin >> maze[i][j];
    if (maze[i][j] == '#') x++;
  }
  sx = 0, sy = 0, gx = W - 1, gy = H - 1;
  cout << bfs() << endl;
  cout << H * W - x - bfs() - 1 << endl;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <vector>
^
Main.java:3: error: illegal character: '#'
#include <string.h>
^
Main.java:4: error: illegal character: '#'
#include <stack>
^
Main.java:5: error: illegal character: '#'
#include <queue>
^
Main.java:6: error: illegal character: '#'
#include <algorithm>
^
Main.java:7: error: illegal character: '#'
#include <climits>
^
Main.java:8: error: illegal character: '#'
#include <cmath>
^
Main.java:9: error: illegal character: '#'
#include <map>
^
Main.java:10: error: illegal character: '#'
#include <set>
^
Main.java:11: error: illegal character: '#'
#include <assert.h>
^
Main.java:12: error: illegal character: '#'
#define REP(i,n) for(ll i=0;i<(n);i++)
^
Main.java:12: error: class, interface, enum, or record expected
#define REP(i,n) for(ll i=0;i<(n);i++)
                            ^
Main.java:12: error: class, interface, enum, or record expected
#define REP(i,n) for(ll i=0;i<(n);i++)
                                  ^
Main.java:13: error: illegal character: '#'
#define MOD 1000000007
^
Main.java:15: error: illegal character: '#'
#ifdef int
^
Main.java:17: error: illegal character: '#'
#else
^
Main.java:18: error: class, interface, enum, or record expected
const int INF = 1010101010;
^
Main.java:19: error: illegal character: '#'
#endif
^
Main.java:20: error: class, interface, enum, or record expected
using namespace std;
^
Main.java:21: error: class, interface, enum, or record expected
typedef long long ll;
^
Main.java:22: error: class, interface, enum, or record expected
typedef vector<vector<ll> > mat;
^
Main.java:23: error: class, interface, enum, or record expected
typedef pair<int, int> P;
^
Main.java:25: error: class, interface, enum, or record expected
const int dx[9] = {-1, 0, 0, 1, -1, -1, 1, 1, 0};
^
Main.java:26: error: class, interface, enum, or record expected
const int dy[9] = {0, -1, 1, 0, -1, 1, -1, 1, 0};
^
Main.java:28: error: class, interface, enum, or record expected
int H, W;
^
Main.java:29: error: class, interface, enum, or record expected
char maze[60][60];
^
Main.java:30: error: class, interface, enum, or record expected
int sx, sy;
^
Main.java:31: error: class, interface, enum, or record expected
int gx, gy;
^
Main.java:32: error: class, interface, enum, or record expected
int d[60][60];  //????????????
^
Main.java:35: error: unnamed classes are a preview feature and are disabled by default.
int bfs()
^
  (use --enable-preview to enable unnamed classes)
Main.java:38: error: ';' expected
  REP(i,H) REP(j,W) d[i][j] = INF;
          ^
Main.java:38: error: ';' expected
  REP(i,H) REP(j,W) d[i][j] = INF;
                   ^
Main.java:45: error: ';' expected
    REP(i,4) {
            ^
Main.java:60: error: not a statement
  cin >> H >> W;
           ^
Main.java:63: error: not a statement
    cin >> maze[i][j];
        ^
Main.java:67: error: not a statement
  cout << bfs() << endl;
                ^
Main.java:68: error: not a statement
  cout << H * W - x - bfs() - 1 << endl;
                                ^
Main.java:62: error: ';' expected
  REP(i,H) REP(j,W) {
          ^
Main.java:62: error: ';' expected
  REP(i,H) REP(j,W) {
                   ^
Main.java:66: error: ';' expected
  sx = 0, sy = 0, gx = W - 1, gy = H - 1;
        ^
Main.java:66: error: ';' expected
  sx = 0, sy = 0, gx = W - 1, gy = H - 1;
                ^
Main.java:66: error: ';' expected
  sx = 0, sy = 0, gx = W - 1, gy = H - 1;
                            ^
43 errors