QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#362045#8507. Clever Cell Choicesucup-team987#AC ✓2ms4496kbC++2310.8kb2024-03-23 13:58:322024-03-23 13:58:32

Judging History

你现在查看的是最新测评结果

  • [2024-03-23 13:58:32]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:4496kb
  • [2024-03-23 13:58:32]
  • 提交

answer

#if __INCLUDE_LEVEL__ == 0

#include __BASE_FILE__

namespace {

void solve() {
  int h, w;
  scan(h, w);
  std::vector<std::string> s(h);
  scan(s);

  std::array<int, 2> n{};
  std::vector id(h, std::vector<int>(w, -1));
  for (const int i : rep(h)) {
    for (const int j : rep(w)) {
      if (s[i][j] == '.') {
        id[i][j] = n[(i + j) % 2]++;
      }
    }
  }

  std::vector<std::pair<int, int>> edges;
  for (const int i : rep(h)) {
    for (const int j : rep(w)) {
      if (s[i][j] != '.') {
        continue;
      }
      if (i + 1 < h && s[i + 1][j] == '.') {
        if ((i + j) % 2 == 0) {
          edges.emplace_back(id[i][j], id[i + 1][j]);
        } else {
          edges.emplace_back(id[i + 1][j], id[i][j]);
        }
      }
      if (j + 1 < w && s[i][j + 1] == '.') {
        if ((i + j) % 2 == 0) {
          edges.emplace_back(id[i][j], id[i][j + 1]);
        } else {
          edges.emplace_back(id[i][j + 1], id[i][j]);
        }
      }
    }
  }

  const auto dm = dulmage_mendelsohn(n[0], n[1], edges);
  const int ans = len(dm[0].second) + len(dm.back().first);
  print(ans);
}

}  // namespace

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::setprecision(DBL_DECIMAL_DIG);

  solve();
}

#else  // __INCLUDE_LEVEL__

#include <bits/stdc++.h>

// https://hitonanode.github.io/cplib-cpp/graph/dulmage_mendelsohn_decomposition.hpp.html

// https://ei1333.github.io/luzhiled/snippets/graph/hopcroft-karp.html
struct BipartiteMatching {
  int V;
  std::vector<std::vector<int>> to;
  std::vector<int> dist;
  std::vector<int> match;
  std::vector<int> used, vv;
  std::vector<int> color;

  BipartiteMatching() = default;
  BipartiteMatching(int V_) : V(V_), to(V_), match(V_, -1), used(V_), color(V_, -1) {}

  void add_edge(int u, int v) {
    assert(u >= 0 and u < V and v >= 0 and v < V and u != v);
    to[u].push_back(v);
    to[v].push_back(u);
  }

  void _bfs() {
    dist.assign(V, -1);
    std::vector<int> q;
    int lq = 0;
    for (int i = 0; i < V; i++) {
      if (!color[i] and !used[i]) q.push_back(i), dist[i] = 0;
    }

    while (lq < int(q.size())) {
      int now = q[lq++];
      for (auto nxt : to[now]) {
        int c = match[nxt];
        if (c >= 0 and dist[c] == -1) q.push_back(c), dist[c] = dist[now] + 1;
      }
    }
  }

  bool _dfs(int now) {
    vv[now] = true;
    for (auto nxt : to[now]) {
      int c = match[nxt];
      if (c < 0 or (!vv[c] and dist[c] == dist[now] + 1 and _dfs(c))) {
        match[nxt] = now, match[now] = nxt;
        used[now] = true;
        return true;
      }
    }
    return false;
  }

  bool _color_bfs(int root) {
    color[root] = 0;
    std::vector<int> q{root};
    int lq = 0;
    while (lq < int(q.size())) {
      int now = q[lq++], c = color[now];
      for (auto nxt : to[now]) {
        if (color[nxt] == -1) {
          color[nxt] = !c, q.push_back(nxt);
        } else if (color[nxt] == c) {
          return false;
        }
      }
    }
    return true;
  }

  int solve() {
    for (int i = 0; i < V; i++) {
      if (color[i] == -1 and !_color_bfs(i)) return -1;
    }
    int ret = 0;
    while (true) {
      _bfs();
      vv.assign(V, false);
      int flow = 0;
      for (int i = 0; i < V; i++) {
        if (!color[i] and !used[i] and _dfs(i)) flow++;
      }
      if (!flow) break;
      ret += flow;
    }
    return ret;
  }

  template <class OStream>
  friend OStream& operator<<(OStream& os, const BipartiteMatching& bm) {
    os << "{N=" << bm.V << ':';
    for (int i = 0; i < bm.V; i++) {
      if (bm.match[i] > i) os << '(' << i << '-' << bm.match[i] << "),";
    }
    return os << '}';
  }
};

struct DirectedGraphSCC {
  int V;
  std::vector<std::vector<int>> to, from;
  std::vector<int> used;
  std::vector<int> vs;
  std::vector<int> cmp;
  int scc_num = -1;

  DirectedGraphSCC(int V = 0) : V(V), to(V), from(V), cmp(V) {}

  void _dfs(int v) {
    used[v] = true;
    for (auto t : to[v])
      if (!used[t]) _dfs(t);
    vs.push_back(v);
  }
  void _rdfs(int v, int k) {
    used[v] = true;
    cmp[v] = k;
    for (auto t : from[v])
      if (!used[t]) _rdfs(t, k);
  }

  void add_edge(int from_, int to_) {
    assert(from_ >= 0 and from_ < V and to_ >= 0 and to_ < V);
    to[from_].push_back(to_);
    from[to_].push_back(from_);
  }

  int FindStronglyConnectedComponents() {
    used.assign(V, false);
    vs.clear();
    for (int v = 0; v < V; v++)
      if (!used[v]) _dfs(v);
    used.assign(V, false);
    scc_num = 0;
    for (int i = (int)vs.size() - 1; i >= 0; i--)
      if (!used[vs[i]]) _rdfs(vs[i], scc_num++);
    return scc_num;
  }

  int _c, _init;
  std::vector<int> _ret_cycle;
  bool _dfs_detectcycle(int now, bool b0) {
    if (now == _init and b0) return true;
    for (auto nxt : to[now])
      if (cmp[nxt] == _c and !used[nxt]) {
        _ret_cycle.emplace_back(nxt), used[nxt] = 1;
        if (_dfs_detectcycle(nxt, true)) return true;
        _ret_cycle.pop_back();
      }
    return false;
  }
  std::vector<int> DetectCycle() {
    int ns = FindStronglyConnectedComponents();
    if (ns == V) return {};
    std::vector<int> cnt(ns);
    for (auto x : cmp) cnt[x]++;
    _c = std::find_if(cnt.begin(), cnt.end(), [](int x) { return x > 1; }) - cnt.begin();
    _init = std::find(cmp.begin(), cmp.end(), _c) - cmp.begin();
    used.assign(V, false);
    _ret_cycle.clear();
    _dfs_detectcycle(_init, false);
    return _ret_cycle;
  }

  DirectedGraphSCC GenerateTopologicalGraph() {
    DirectedGraphSCC newgraph(scc_num);
    for (int s = 0; s < V; s++)
      for (auto t : to[s]) {
        if (cmp[s] != cmp[t]) newgraph.add_edge(cmp[s], cmp[t]);
      }
    return newgraph;
  }
};

struct SATSolver : DirectedGraphSCC {
  int nb_sat_vars;
  std::vector<int> solution;
  SATSolver(int nb_variables = 0)
      : DirectedGraphSCC(nb_variables * 2), nb_sat_vars(nb_variables), solution(nb_sat_vars) {}
  void add_x_or_y_constraint(bool is_x_true, int x, bool is_y_true, int y) {
    assert(x >= 0 and x < nb_sat_vars);
    assert(y >= 0 and y < nb_sat_vars);
    if (!is_x_true) x += nb_sat_vars;
    if (!is_y_true) y += nb_sat_vars;
    add_edge((x + nb_sat_vars) % (nb_sat_vars * 2), y);
    add_edge((y + nb_sat_vars) % (nb_sat_vars * 2), x);
  }
  bool run() {
    FindStronglyConnectedComponents();
    for (int i = 0; i < nb_sat_vars; i++) {
      if (cmp[i] == cmp[i + nb_sat_vars]) return false;
      solution[i] = cmp[i] > cmp[i + nb_sat_vars];
    }
    return true;
  }
};

std::vector<std::pair<std::vector<int>, std::vector<int>>> dulmage_mendelsohn(
    int L, int R, const std::vector<std::pair<int, int>>& edges) {
  for (auto p : edges) {
    assert(0 <= p.first and p.first < L);
    assert(0 <= p.second and p.second < R);
  }

  BipartiteMatching bm(L + R);
  for (auto p : edges) bm.add_edge(p.first, L + p.second);
  bm.solve();

  DirectedGraphSCC scc(L + R);
  for (auto p : edges) scc.add_edge(p.first, L + p.second);
  for (int l = 0; l < L; ++l) {
    if (bm.match[l] >= L) scc.add_edge(bm.match[l], l);
  }

  int nscc = scc.FindStronglyConnectedComponents();
  std::vector<int> cmp_map(nscc, -2);

  std::vector<int> vis(L + R);
  std::vector<int> st;
  for (int c = 0; c < 2; ++c) {
    std::vector<std::vector<int>> to(L + R);
    auto color = [&L](int x) { return x >= L; };
    for (auto p : edges) {
      int u = p.first, v = L + p.second;
      if (color(u) != c) std::swap(u, v);
      to[u].push_back(v);
      if (bm.match[u] == v) to[v].push_back(u);
    }
    for (int i = 0; i < L + R; ++i) {
      if (bm.match[i] >= 0 or color(i) != c or vis[i]) continue;
      vis[i] = 1, st = {i};
      while (!st.empty()) {
        int now = st.back();
        cmp_map[scc.cmp[now]] = c - 1;
        st.pop_back();
        for (int nxt : to[now]) {
          if (!vis[nxt]) vis[nxt] = 1, st.push_back(nxt);
        }
      }
    }
  }

  int nset = 1;
  for (int n = 0; n < nscc; ++n) {
    if (cmp_map[n] == -2) cmp_map[n] = nset++;
  }
  for (auto& x : cmp_map) {
    if (x == -1) x = nset;
  }
  nset++;

  std::vector<std::pair<std::vector<int>, std::vector<int>>> groups(nset);

  for (int l = 0; l < L; ++l) {
    if (bm.match[l] < 0) continue;
    int c = cmp_map[scc.cmp[l]];
    groups[c].first.push_back(l);
    groups[c].second.push_back(bm.match[l] - L);
  }
  for (int l = 0; l < L; ++l) {
    if (bm.match[l] >= 0) continue;
    int c = cmp_map[scc.cmp[l]];
    groups[c].first.push_back(l);
  }
  for (int r = 0; r < R; ++r) {
    if (bm.match[L + r] >= 0) continue;
    int c = cmp_map[scc.cmp[L + r]];
    groups[c].second.push_back(r);
  }

  return groups;
}

template <class T, class U = T>
bool chmin(T& x, U&& y) {
  return y < x && (x = std::forward<U>(y), true);
}

template <class T, class U = T>
bool chmax(T& x, U&& y) {
  return x < y && (x = std::forward<U>(y), true);
}

template <std::signed_integral T = int>
T inf() {
  T ret;
  std::memset(&ret, 0x3f, sizeof(ret));
  return ret;
}

template <std::floating_point T>
T inf() {
  return std::numeric_limits<T>::infinity();
}

template <class T>
concept Range = std::ranges::range<T> && !std::convertible_to<T, std::string_view>;

template <class T>
concept Tuple = std::__is_tuple_like<T>::value && !Range<T>;

namespace std {

istream& operator>>(istream& is, Range auto&& r) {
  for (auto&& e : r) {
    is >> e;
  }
  return is;
}

istream& operator>>(istream& is, Tuple auto&& t) {
  return apply([&](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}

ostream& operator<<(ostream& os, Range auto&& r) {
  for (string_view sep = ""; auto&& e : r) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

ostream& operator<<(ostream& os, Tuple auto&& t) {
  const auto f = [&](auto&... xs) -> ostream& {
    [[maybe_unused]] string_view sep = "";
    ((os << exchange(sep, " ") << xs), ...);
    return os;
  };
  return apply(f, t);
}

}  // namespace std

void scan(auto&&... xs) { std::cin >> std::tie(xs...); }
void print(auto&&... xs) { std::cout << std::tie(xs...) << '\n'; }

template <class F>
class fix {
 public:
  explicit fix(F f) : f_(std::move(f)) {}

  decltype(auto) operator()(auto&&... xs) const {
    return f_(std::ref(*this), std::forward<decltype(xs)>(xs)...);
  }

 private:
  F f_;
};

inline auto rep(int l, int r) { return std::views::iota(std::min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }

namespace ranges = std::ranges;
namespace views = std::views;

using i64 = std::int64_t;

#define len(...) static_cast<int>(ranges::size(__VA_ARGS__))

#endif  // __INCLUDE_LEVEL__

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3580kb

input:

3 3
#.#
...
#.#

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 1ms
memory: 3868kb

input:

3 3
..#
...
...

output:

0

result:

ok 1 number(s): "0"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1 4
...#

output:

2

result:

ok 1 number(s): "2"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

1 5
####.

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

1 6
#..###

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

2 5
....#
###.#

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

2 6
...##.
.#.###

output:

4

result:

ok 1 number(s): "4"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

5 5
##...
##.#.
##.##
##.#.
.##..

output:

7

result:

ok 1 number(s): "7"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

6 6
...##.
#..#..
......
..#...
#...##
.#....

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

10 10
####.#...#
.#.###....
#....#..#.
.....#.#..
##.#..#.#.
..#..##...
.##.#####.
#######.##
.#.#.##..#
.#.###.##.

output:

26

result:

ok 1 number(s): "26"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

10 10
..#..#.###
.#######.#
.#.####.#.
......####
#..#..#.#.
...#.###.#
#.#...#.#.
.#...#....
...#.#.#.#
...###....

output:

21

result:

ok 1 number(s): "21"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3652kb

input:

15 15
#......#.#.###.
#.##...####..#.
##.....##.##.#.
#.###.#..#...##
....###.##.#.#.
.#..#.###.##.#.
######.#.####.#
.#....#..####..
.....#.###.##..
#..##.###.#####
#.##.#####..###
.#######..##.#.
##....#.##...#.
....#####.##.##
...#.#........#

output:

51

result:

ok 1 number(s): "51"

Test #13:

score: 0
Accepted
time: 1ms
memory: 3672kb

input:

15 15
###.#......#...
#.....#.#.###.#
#..#.#.###..#..
.#####.##.#..#.
...#.##.#..#.#.
#.#.###.....###
......#..##....
..##..#.#.#...#
..#..#..#......
....####...#..#
.####..#.#.##.#
###.#..#.#.#...
.#.##.##....##.
.#.#####.#..#.#
#.#.#.##.#.....

output:

61

result:

ok 1 number(s): "61"

Test #14:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

20 20
####....##.#####.##.
...####.##..#.####..
#.#.....#....##..###
###..###.#.#..#..###
##.##..#.##.####....
#...###.##.###.##...
.###...#####.##....#
#...###...##........
##.#.#.#.###.......#
#...##.##.#..##.##..
..##.##.######....##
#.#....#.##.##.##..#
##.....#..#.########
##....##.###...#....
...

output:

95

result:

ok 1 number(s): "95"

Test #15:

score: 0
Accepted
time: 1ms
memory: 3752kb

input:

20 20
.##.#.#.#..##..##.#.
..#.##.##.....##..##
.#....##...####..#..
##..###..#.#..##....
....#.##.##.###...##
.#.#.##.#..###....#.
######.#..#....#.#..
.##.###..##..##.###.
#.....#.#..#.##.#.#.
###.#####.##..#.##.#
...###.####.##...#.#
.#.....#.#.#.#..###.
#.#...#####..##.####
..####.##..##.#.#.##
...

output:

109

result:

ok 1 number(s): "109"

Test #16:

score: 0
Accepted
time: 1ms
memory: 3688kb

input:

30 30
###...###....#..#.#.#######...
.##..#.###.#.####.#...#..#.#..
.##..#######..##...#....##...#
..###..#..###...#.##.....#..##
#.#.#.#.#...###.######..#....#
###..##..###.#.###.#.####..#..
.....#...####..####..##.#.##.#
..#...######.##....#..###..###
..#####......#.#...##...#..##.
##..#.#.#.##......

output:

196

result:

ok 1 number(s): "196"

Test #17:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

30 30
######....###.#..#..###.#.##.#
.#..#...#.##..#.##...#...#####
##.#.##..##.#..###.#.#...####.
.####.###..##..#..#.#####..#.#
....##.##...#...##.####..####.
..###.##.##...##.##.###.####.#
#####......#.#...#..........#.
..#.....###..##.##..##.#.#####
..##...#.##.#.#.#..#.#.#.##...
...#.#.##..###....

output:

196

result:

ok 1 number(s): "196"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

40 40
......##...#.##..###.##.#.....#.#.#..#.#
#..###...####.####..###.#.#.#..#.##..##.
############.#.#...##..#...#........#.##
##.###.##########...###...####.##..#####
.###.#.##.##....##...#.##.#..#..##.#..#.
##...####.##.###.#.#.##...##..####.#####
#####..##.###.##.#.#.....####..##...##..
.#..###...

output:

290

result:

ok 1 number(s): "290"

Test #19:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

40 40
.####.####.....##.......#....########..#
.#.#....#####..#.##.###..#..#.#...##.#.#
.##.####..#.#...#.######..#.....##.#.##.
.##..##...#...#.#.#..#.###.....#..##.##.
..###.#.#....#######...#.##.##...##...#.
.##..#......##.##########.##.###..#..#.#
###.##.#.##...#.#####...###..##.#.#..###
#.###.....

output:

307

result:

ok 1 number(s): "307"

Test #20:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

50 50
#..#..###.###.####..#..#.##.#.##...#.#...########.
..#.##.##..##..##.##.##.##...#.#.####.#.##...##..#
....##.#.#..#.#.#.###...##.###.#...#.##..#..#..###
#.###.#.##.#......##...#..#..#..##..#####.##.#....
.##.####..##.#..#...##...#..#...##..##.##..#.##...
.###.#..#..####....##...#......##..#.##...

output:

488

result:

ok 1 number(s): "488"

Test #21:

score: 0
Accepted
time: 1ms
memory: 3948kb

input:

50 50
...##..#.#.##...#..##........##..###..##..#......#
.......#.#..#####.##.##.##.###.#.##.#.#..##......#
...##.##.########.##...#...#...#####...###.####.#.
#....###..###.###......##.#####..##.#...#.#...###.
#.##.##...#.#....##..##.##..##.#..####..#####.##..
.##.##.#.##...#.##.#.#....##..#..#.##.#...

output:

494

result:

ok 1 number(s): "494"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3528kb

input:

1 10
.#........

output:

1

result:

ok 1 number(s): "1"

Test #23:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

1 11
#..........

output:

0

result:

ok 1 number(s): "0"

Test #24:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

1 21
#.......#............

output:

4

result:

ok 1 number(s): "4"

Test #25:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

2 12
..#.........
......#.....

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

2 22
....#.................
..........#......#..#.

output:

0

result:

ok 1 number(s): "0"

Test #27:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

33 3
#..
...
...
...
.#.
...
...
...
...
.#.
...
...
...
...
..#
...
...
...
...
...
...
..#
..#
...
...
...
...
...
...
...
.#.
...
.#.

output:

3

result:

ok 1 number(s): "3"

Test #28:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

42 1
.
.
.
.
.
.
#
.
.
.
.
.
.
.
.
#
.
.
.
.
.
#
.
.
.
.
#
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

output:

11

result:

ok 1 number(s): "11"

Test #29:

score: 0
Accepted
time: 1ms
memory: 3756kb

input:

13 37
##........#..........................
....................#................
..........#.............#............
..............#.....#.....#..........
....#....#.....................##....
....#........#.........#.............
........#.......#....................
....#............##............

output:

221

result:

ok 1 number(s): "221"

Test #30:

score: 0
Accepted
time: 1ms
memory: 3960kb

input:

31 13
.....#......#
........#....
....#.#......
....#........
.............
.#.........#.
......#......
............#
..#.#......#.
.............
.......#.....
.....#.......
..#..........
.##.#........
.#..#........
..........##.
.............
...........##
............#
.............
.......#.#...
...

output:

184

result:

ok 1 number(s): "184"

Test #31:

score: 0
Accepted
time: 1ms
memory: 4120kb

input:

44 44
...................#...........#............
.#............#.#..#.#......................
...#....#.........##....#...##..............
.......#....................................
.....##...#...##..........#.................
..##.#...........#.........##........#......
.....#.....................

output:

833

result:

ok 1 number(s): "833"

Test #32:

score: 0
Accepted
time: 0ms
memory: 4160kb

input:

49 46
......##.................#....................
...#.................#.....#..#..........#.#..
#.....#...............#......##....#.....#....
..........#............##...................##
...#......#.#..............###..#..........#..
..................................#...........
...........#...

output:

956

result:

ok 1 number(s): "956"

Test #33:

score: 0
Accepted
time: 2ms
memory: 4288kb

input:

50 50
..#..#................#.#.......#.................
#...........................#..#..................
...#..............#....#...............#..........
.........#..........#........................#....
...#....#..........#..#.#................##..#....
...#.........#.#.#..................#.....

output:

1020

result:

ok 1 number(s): "1020"

Test #34:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

1 7
.......

output:

4

result:

ok 1 number(s): "4"

Test #35:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

1 10
..........

output:

0

result:

ok 1 number(s): "0"

Test #36:

score: 0
Accepted
time: 1ms
memory: 4188kb

input:

31 35
...................................
...................................
...................................
...................................
...................................
...................................
...................................
...................................
.........

output:

543

result:

ok 1 number(s): "543"

Test #37:

score: 0
Accepted
time: 1ms
memory: 4136kb

input:

33 33
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.................................
.........................

output:

545

result:

ok 1 number(s): "545"

Test #38:

score: 0
Accepted
time: 2ms
memory: 4064kb

input:

42 42
..........................................
..........................................
..........................................
..........................................
..........................................
..........................................
.......................................

output:

0

result:

ok 1 number(s): "0"

Test #39:

score: 0
Accepted
time: 2ms
memory: 4432kb

input:

47 48
................................................
................................................
................................................
................................................
................................................
................................................
...

output:

0

result:

ok 1 number(s): "0"

Test #40:

score: 0
Accepted
time: 0ms
memory: 4496kb

input:

50 50
...##.#......#....#............#...........#......
...#........#.............#.....##...#.....#.....#
.......#..#..#.#...........#...............#......
.......#........#......#.................#......#.
#....................................#...#........
........#.................#.........#.....

output:

909

result:

ok 1 number(s): "909"

Test #41:

score: 0
Accepted
time: 1ms
memory: 4128kb

input:

50 50
.##...###......#......#.......###.....#.#..#.#....
.#...#.####........#.##......#...##..#..#.........
..###..#....#.......#..##.......#...#.....#...#..#
##.#....#...#...#...##.#..##.#.#..#.......#...##..
##.#..#........#.#..#.##.....#..##.....##..#...#..
.............#..#....##.....#..##.....#...

output:

688

result:

ok 1 number(s): "688"

Test #42:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

50 50
#....#.####.###........##.#...#......#..##.##.##..
#####.#.#.######..##.###.....#.#.#...#.###.#.#....
.#.#####.#..##.#...#....#.##...#.##..####.#.#...##
#.#...##..##....#....######.##.####...#.##.##.####
#..###.....#.##..###...###.##...#..####....##.##.#
#....#.#...#.##...###..###....#.###..#....

output:

536

result:

ok 1 number(s): "536"

Test #43:

score: 0
Accepted
time: 1ms
memory: 3820kb

input:

50 50
#####.#####.###..###..#######.##.#.####.#.#.###.##
###.#.####.##...##.#.##.##..####.######.#..###.#..
###...####.########..###.###.###..###.#####..#####
###########..##.###..#..#####..#....##..######.#.#
#######.####.#.#####.#...######..#.#####.#.#######
####.#.##.#######..######.##.###.##.###...

output:

371

result:

ok 1 number(s): "371"

Test #44:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

50 50
..##.####.#..#.##..#.#.#####..####.########.###.##
###.###..#.##.##..########...#########..##########
#########.#######.###..####################..#####
#######.##.###.###.###.#..####.#####...###..###.#.
##.#.##############.###########.####...##########.
.....#.#.#####.#...#.##################...

output:

299

result:

ok 1 number(s): "299"

Test #45:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

50 50
############.########################.###########.
####.##########.#############.#############.######
#####.#######.###############.#############.#.##.#
..#.##.#####..###.###########.########.####.######
###############.#.########.##############.######..
######.#################.#..##.########...

output:

189

result:

ok 1 number(s): "189"

Test #46:

score: 0
Accepted
time: 2ms
memory: 4300kb

input:

43 44
.................#....#..#...............##.
....#..#.............................#......
.............#.....................#.#......
.#.....#......#...............#.............
#...............#...#...............#.......
.#.....#..#...........#.......#.............
..#........................

output:

776

result:

ok 1 number(s): "776"

Test #47:

score: 0
Accepted
time: 1ms
memory: 3988kb

input:

15 49
.##..#........#....#....##.....#..#.......##...#.
...#.....##....##...#.#...........#..#.........#.
#..#.........##.....#.#..#.....#.#.#..#......#...
.................#...........#.....#...........#.
..#..#.....##...#......#....#.....#........#..#..
#.#.......#..........#..#...#..................

output:

218

result:

ok 1 number(s): "218"

Test #48:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5 10
#..#......
.#....##..
..###...##
..#...#..#
#....#....

output:

3

result:

ok 1 number(s): "3"

Test #49:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

49 49
#.#.##...#.....#..##..##..##....##..###....##.##.
####.#....#......##.........##...##......#.#...##
..#...#.##....#......###...##..#.##.#.......##.#.
.....###..#....#.##.#....####..##..#..##....#..#.
#####..#...#....#.######......#..#....###..#.###.
.#.#.....###..#...#..#..#####...#.##......#....

output:

530

result:

ok 1 number(s): "530"

Test #50:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

22 22
###.#.#######.###.##.#
..###.##...#.#.#..#..#
.####.####.###.#.....#
#####..#.##.###..#.#..
###.#.#.#.#...###.###.
...###....##..##.....#
.#..##.#......#.#..#.#
.###.##.#.....#...#.#.
##..#.#######.##...#..
##...###...##.#..#####
##.#..##.##....##.###.
..#.##...##.###.##.##.
#####.##.#.#.#.##....

output:

105

result:

ok 1 number(s): "105"

Test #51:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

13 31
.###..##.#..##.#..#.#..#.###..#
.#...######....##.####.#..#.###
##..##..######...#.#####..#####
###.######.#..#.#.##..##.###.#.
##############.###..###.##.#.#.
##..##...#..#..#####.##.##....#
.###.#.##..#.....#...#..##.##.#
####.##.....######.##.#.##.#..#
...####.#.###.###.##.#..#.#.#..
..#..#...

output:

56

result:

ok 1 number(s): "56"

Test #52:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

33 33
#.###.##..####.##.##..#.##..#####
#.#.####.##.####.#####.##.####.##
#####...#.##.###########.#.####.#
###.##....##.#######.####.#######
##################.##..#######..#
##.###.#.###.##########.###.##..#
.#..#####.#####.#####.####..#.###
.##.#.###.####.#####.####.###.##.
.###.#..############.#...

output:

160

result:

ok 1 number(s): "160"

Test #53:

score: 0
Accepted
time: 2ms
memory: 4276kb

input:

50 50
......#.....................................######
......#.....................................#.....
......#.....................................#.....
......#.....................................#.....
......#.....................................#.....
......#...................................

output:

267

result:

ok 1 number(s): "267"

Test #54:

score: 0
Accepted
time: 0ms
memory: 4220kb

input:

50 50
......#..#....###.....#.#......#..................
..#....#......#...................................
.###..........#...#.....#......#.....#...#.##.....
#.........#...#.....#.............................
#.............#..#..#.....#.....#.........##......
..............#..#....#....#........#.....

output:

862

result:

ok 1 number(s): "862"

Test #55:

score: 0
Accepted
time: 2ms
memory: 4192kb

input:

50 50
...#..............#.........#.......#........#....
.........#.#.#..#...............#.#..............#
.............#...#....##......#.#..............#..
.#.#...#.......##...........##...#....#...........
.#.#....#..#.......#.#....#.#...........#.........
..##.......#..........#...#.#....#.#......

output:

926

result:

ok 1 number(s): "926"

Test #56:

score: 0
Accepted
time: 2ms
memory: 4296kb

input:

50 50
............................................#.....
............................................#.....
............................................#.....
............................................#.....
............................................#.....
..........................................

output:

406

result:

ok 1 number(s): "406"

Test #57:

score: 0
Accepted
time: 0ms
memory: 4144kb

input:

50 50
.........#########################################
..................................................
..................................................
..................................................
###################################...............
..................................#.......

output:

664

result:

ok 1 number(s): "664"

Test #58:

score: 0
Accepted
time: 0ms
memory: 4116kb

input:

50 50
.#........................................#.#.##..
.#........#...............................#...##..
##........................................#...##..
.#.......................#.............#..#...##..
###########################################...##..
..........................................

output:

650

result:

ok 1 number(s): "650"

Test #59:

score: 0
Accepted
time: 2ms
memory: 4172kb

input:

50 50
..#...#.....#.........#...#.#....#..#...#.........
............#..#...#....##.........#....#..#......
............#.......#..................##....#####
...#........#................#..........#....#..#.
............#....#.##........#....#.....#....#....
...##...#...###########################...

output:

939

result:

ok 1 number(s): "939"

Test #60:

score: 0
Accepted
time: 1ms
memory: 3884kb

input:

50 50
.#######..####.....##..#....#.#.##.####...#..#...#
#.##..###.####.###.#.........####.##....#.....##..
##.#.##..####.####.##.##..#...#.#......###.#..##..
###..#.#..#####.#####....####...#.#########...#.#.
.#.###.##.###...##.##..#.##.#...#..#.###.######..#
###..##..###..#.#..#.####.#..###.#..#.....

output:

429

result:

ok 1 number(s): "429"

Test #61:

score: 0
Accepted
time: 2ms
memory: 4284kb

input:

50 50
..##................................#..#.....#....
..##................................#..#.....#....
..##................................#..#.....#....
..#####.............................#..#.....#....
..##..#.............................#..#.....#....
..##..#.............................#.....

output:

0

result:

ok 1 number(s): "0"

Test #62:

score: 0
Accepted
time: 2ms
memory: 4460kb

input:

50 50
.............................#......#...#...#.....
.............................#......#...#...#.....
.............................#......#...#...#.....
.............................#......#...#...#.....
.............................#......#...#...#.....
.............................#......#.....

output:

264

result:

ok 1 number(s): "264"

Test #63:

score: 0
Accepted
time: 2ms
memory: 4440kb

input:

50 50
.........#..#....................##..#......#.....
.........#..#....................##..#......#.....
.........#..#....................##..#......#.....
.........#..#....................##..#...#..#.....
.........#..#....................##..#......#.....
.........#..#....................##..#....

output:

763

result:

ok 1 number(s): "763"

Test #64:

score: 0
Accepted
time: 1ms
memory: 4132kb

input:

50 50
.....#....#.###.#.....#...........................
.....#....#.###.#.....#......................#####
.....#....#.###.#.....############################
.....#....#.###.#####...#.........................
.....#....#.###.#...#...#.........................
.....#....#.###.#...#...#.................

output:

365

result:

ok 1 number(s): "365"

Test #65:

score: 0
Accepted
time: 2ms
memory: 4064kb

input:

50 50
..........................................##.#.#..
..........................................##.#.#..
############################################.#.#..
..#.........#................#............##.#.#..
..#.........#................#............##.#.#..
#############................#............

output:

301

result:

ok 1 number(s): "301"

Extra Test:

score: 0
Extra Test Passed