QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153434#5472. Secure the Top Secretideograph_advantageWA 10ms17680kbC++179.1kb2023-08-30 01:57:302023-08-30 01:57:31

Judging History

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

  • [2023-08-30 01:57:31]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:17680kb
  • [2023-08-30 01:57:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define iter(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL
void debug(){cerr << "\n";}
template<class T, class ... U>
void debug(T a, U ... b){ cerr << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
    while(l != r) cerr << *l << " ", l++;
    cerr << "\n";
}
#else
#define debug(...) void()
#define pary(...) void()
#endif

template<class A, class B>
ostream& operator<<(ostream& o, pair<A, B> p){
    return o << '(' << p.ff << ',' << p.ss << ')';
}

const ll MAX = 1e9;
#define maxn 250000
#define inf 1000000000
struct MCMF{
    struct edge {
        ll from, to, cap, flow, cost, rev;
    } * past[maxn];
    vector<edge> G[maxn];
    bitset<maxn>inq;
    ll dis[maxn], up[maxn], s, t, mx, n;
    bool BellmanFord(ll &flow, ll &cost) {
        fill(dis, dis+n, inf);
        queue<ll> q;
        q.push(s);
        inq.reset(), inq[s] = 1;
        up[s] = mx - flow, past[s] = 0, dis[s] = 0;
        while (!q.empty()) {
            ll u = q.front();
            q.pop(), inq[u] = 0;
            if (!up[u]) continue;
            for (auto &e :G[u]) {
                if (e.flow != e.cap && dis[e.to] > dis[u] + e.cost) {
                    dis[e.to] = dis[u] + e.cost, past[e.to] = &e;
                    up[e.to] = min(up[u], e.cap - e.flow);
                    if (!inq[e.to]) inq[e.to] = 1, q.push(e.to);
                }
            }
        }
        if (dis[t] == inf) return 0;
        flow += up[t], cost += up[t] * dis[t];
        for (ll i = t;past[i];i = past[i]->from) {
            auto &e = *past[i];
            e.flow += up[t], G[e.to][e.rev].flow -= up[t];
        }
        return 1;
    }
    ll MinCostMaxFlow(ll _s, ll _t, ll &cost) {
        s = _s, t = _t, cost = 0;
        ll flow = 0;
        while (BellmanFord(flow, cost));
        //debug("ok", flow, cost);

        for(int i = 0; i < n; i++){
            for(auto j : G[i]){
                if(j.flow > 0) debug("edge", j.from, j.to, j.flow);
            }
        }

        return flow;
    }
    void init(ll _n, ll _mx) {
        n = _n, mx = _mx;
        for (int i = 0;i < n;i++) G[i].clear();
    }
    void add_edge(ll a, ll b, ll cap, ll cost) {
        debug("add_edge", a, b, cap, cost);
        G[a].pb(edge{a, b, cap, 0, cost, SZ(G[b])});
        G[b].pb(edge{b, a, 0, 0, -cost, SZ(G[a]) - 1});
    }
} flow;

#define X ff
#define Y ss
struct border{
    pii A, B, cell;
    int side;
};
bool operator==(border a, border b){
    return a.A == b.A && a.B == b.B && a.cell == b.cell && a.side == b.side;
}
ostream& operator<<(ostream& o, border b){
    return o << '(' << b.A << ',' << b.B << ',' << b.cell << ',' << b.side << ')';
}

pair<pii, pii> get_edge(int x, int y, int side){
    if(side == 0) return {mp(x, y), mp(x - 1, y)};
    if(side == 1) return {mp(x - 1, y), mp(x - 1, y - 1)};
    if(side == 2) return {mp(x - 1, y - 1), mp(x, y - 1)};
    if(side == 3) return {mp(x, y - 1), mp(x, y)};
    assert(false);
}

pii get_adj(int x, int y, int side){
    if(side == 0) return {x, y + 1};
    if(side == 1) return {x - 1, y};
    if(side == 2) return {x, y - 1};
    if(side == 3) return {x + 1, y};
    assert(false);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cerr.tie(0);
    
    int n, m;
    cin >> n >> m;
    flow.init((n + 1) * (m + 1) + 4, 1e9);

    auto addedge = [&](int x1, int y1, int x2, int y2, int w){
        if(x1 == x2 && (x1 == 0 || x1 == n)) return;
        if(y1 == y2 && (y1 == 0 || y1 == m)) return;
        flow.add_edge(x1 * (m + 1) + y1, x2 * (m + 1) + y2, 2 - w, w);
        flow.add_edge(x2 * (m + 1) + y2, x1 * (m + 1) + y1, 2 - w, w);
    };
    pii S, U, T;
    vector<string> s(n + 2);
    s[0] = s[n + 1] = string(m + 2, '#');
    for(int i = 1; i <= n; i++){
        cin >> s[i];
        s[i] = "#" + s[i] + "#";
        for(int j = 1; j <= m; j++){
            if(s[i][j] == 'S') S = mp(i, j);
            if(s[i][j] == 'T') T = mp(i, j);
            if(s[i][j] == 'U') U = mp(i, j);
        }
    }

    int K;
    cin >> K;
    vector<pair<pii, pii>> wall;
    for(int i = 0; i < K; i++){
        int x, y;
        char d;
        cin >> x >> y >> d;
        if(d == 'b') wall.pb(mp(x, y - 1), mp(x, y));
        else wall.pb(mp(x - 1, y), mp(x, y));
    }

    vector<vector<int>> vst(n + 2, vector<int>(m + 2));
    vector<pii> dir4 = {mp(0, 1), mp(1, 0), mp(-1, 0), mp(0, -1)};
    vector<pii> dir8;
    for(int i = -1; i <= 1; i++) for(int j = -1; j <= 1; j++) if(i != 0 || j != 0) dir8.pb(mp(i, j));
    auto bfs = [&](int sx, int sy, int t, vector<pii> &dir){
        queue<pii> q;
        q.push(mp(sx, sy));
        vst[sx][sy] = t;
        while(!q.empty()){
            auto [x, y] = q.front();
            q.pop();
            for(auto [dx, dy] : dir){
                int nx = x + dx, ny = y + dy;
                if(nx < 0 || nx > n + 1 || ny < 0 || ny > m + 1) continue;
                if(vst[nx][ny]) continue;
                if(t == 1 && s[nx][ny] == '#') continue;
                vst[nx][ny] = t;
                q.push(mp(nx, ny));
            }
        }
    };
    bfs(S.X, S.Y, 1, dir4);
    for(int i = 0; i <= n + 1; i++) pary(iter(vst[i]));
    bfs(0, 0, -1, dir8);
    for(int i = 0; i <= n + 1; i++) pary(iter(vst[i]));

    if(vst[U.X][U.Y] != 1){
        cout << "-1\n";
        return 0;
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(vst[i][j]) continue;
            addedge(i, j, i, j - 1, 0);
            addedge(i, j, i - 1, j, 0);
            addedge(i - 1, j - 1, i, j - 1, 0);
            addedge(i - 1, j - 1, i - 1, j, 0);
        }
    }

    vector<border> bor;
    {
        int side;
        if(T.X == 1) side = 1;
        else if(T.X == n) side = 3;
        else if(T.Y == 1) side = 2;
        else side = 0;
        auto [A, B] = get_edge(T.X, T.Y, side);
        bor.pb(border({A, B, T, side}));
    }
    
    int lst = 0;
    char c1 = 'T';
    int s1 = (n + 1) * (m + 1);
    int s2 = s1 + 1;
    int t1 = s2 + 1;
    int t2 = t1 + 1;
    bool ST = false;
    vector<vector<bool>> bad(n + 2, vector<bool>(m + 2));
    auto zuoshi = [&](int nxt, char c2, int to){
        //debug("check zuoshi", lst, c2, SZ(bor));
        if(c2 == '.') return;
        debug("zuoshi", lst, nxt, c1, c2);
        if(mp(c1, c2) == mp('S', 'U') ||
           mp(c1, c2) == mp('U', 'S')){
            debug("OK SU");
            for(int i = lst; i < to; i++){
                auto [A, B, cell, side] = bor[i];
                //debug(bor[i]);
                flow.add_edge(s1, A.X * (m + 1) + A.Y, 2, 0);
                flow.add_edge(s1, B.X * (m + 1) + B.Y, 2, 0);
            }
        }
        else if(mp(c1, c2) == mp('U', 'T') ||
                mp(c1, c2) == mp('T', 'U')){
            debug("OK UT");
            for(int i = lst; i < to; i++){
                auto [A, B, cell, side] = bor[i];
                //debug(bor[i]);
                flow.add_edge(A.X * (m + 1) + A.Y, t1, 2, 0);
                flow.add_edge(B.X * (m + 1) + B.Y, t1, 2, 0);
            }
        }
        else if(mp(c1, c2) == mp('S', 'T') ||
                mp(c1, c2) == mp('T', 'S')){
            debug("OK ST");
            for(int i = lst; i < to; i++){
                auto [A, B, cell, side] = bor[i];
                //debug(bor[i]);
                bad[A.X][A.Y] = bad[B.X][B.Y] = true;
            }
            ST = true;
        }
        lst = nxt;
        c1 = c2;
        //debug("ok zuoshi");
    };

    while(true){
        auto [A, B, cell, side] = bor.back();
        debug("border", A, B, cell, side);
        //pary(iter(bor));
        zuoshi(SZ(bor), s[cell.X][cell.Y], SZ(bor) - 1);
        if(SZ(bor) > 1 && bor.front() == bor.back()) break;
        auto [tx, ty] = get_adj(cell.X, cell.Y, (side + 1) % 4);
        if(vst[tx][ty] == -1){
            auto [nA, nB] = get_edge(cell.X, cell.Y, (side + 1) % 4);
            bor.pb(border({nA, nB, cell, (side + 1) % 4}));
            continue;
        }
        auto [nx, ny] = get_adj(tx, ty, side);
        if(vst[nx][ny] == -1){
            auto [nA, nB] = get_edge(tx, ty, side);
            bor.pb(border({nA, nB, mp(tx, ty), side}));
            continue;
        }
        zuoshi(SZ(bor), s[tx][ty], SZ(bor));
        auto [nA, nB] = get_edge(nx, ny, (side - 1 + 4) % 4);
        bor.pb(border({nA, nB, mp(nx, ny), (side - 1 + 4) % 4}));
    }
    if(!ST){
        cout << "-1\n";
        return 0;
    }
    //debug("ok");

    for(auto [p1, p2] : wall){
        if(bad[p1.X][p1.Y] || bad[p2.X][p2.Y]) continue;
        addedge(p1.X, p1.Y, p2.X, p2.Y, 1);
    }

    flow.add_edge(s2, s1, 2, 0);
    flow.add_edge(t1, t2, 2, 0);
    debug("st", s1, s2, t1, t2);

    ll ans = MAX;
    if(flow.MinCostMaxFlow(s2, t2, ans) < 2) cout << "-1\n";
    else cout << ans << "\n";
}

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 13904kb

input:

3 3
S..
#..
U.T
7
1 2 b
1 3 b
2 2 b
2 2 r
2 3 b
3 1 r
3 2 r

output:

3

result:

ok single line: '3'

Test #2:

score: 0
Accepted
time: 3ms
memory: 11856kb

input:

2 2
ST
.U
4
1 1 r
1 1 b
1 2 b
2 1 r

output:

-1

result:

ok single line: '-1'

Test #3:

score: 0
Accepted
time: 4ms
memory: 13928kb

input:

7 10
U.........
..........
###.......
..........
.......###
..........
S........T
18
4 4 r
5 4 r
6 7 r
7 7 r
3 4 b
3 5 b
3 6 b
3 7 b
3 8 b
3 9 b
3 10 b
5 1 b
5 2 b
5 3 b
5 4 b
5 5 b
5 6 b
5 7 b

output:

14

result:

ok single line: '14'

Test #4:

score: 0
Accepted
time: 3ms
memory: 10012kb

input:

2 5
.T.#S
....U
10
1 3 b
1 1 r
1 1 b
2 1 r
1 2 b
1 5 b
2 2 r
1 2 r
2 3 r
2 4 r

output:

-1

result:

ok single line: '-1'

Test #5:

score: 0
Accepted
time: 3ms
memory: 11808kb

input:

5 5
U.S..
.....
.....
.....
.T...
12
2 4 b
4 1 b
2 2 r
1 5 b
2 2 b
4 3 b
5 3 r
1 2 b
3 2 r
2 1 r
3 3 r
2 4 r

output:

-1

result:

ok single line: '-1'

Test #6:

score: 0
Accepted
time: 4ms
memory: 14148kb

input:

5 4
....
...U
....
S#..
.#T.
12
3 4 b
2 1 b
4 3 r
2 2 b
4 3 b
3 3 r
2 3 r
1 1 b
2 2 r
4 4 b
3 1 b
1 3 r

output:

-1

result:

ok single line: '-1'

Test #7:

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

input:

3 3
UST
###
.#.
2
1 1 r
1 2 r

output:

-1

result:

ok single line: '-1'

Test #8:

score: 0
Accepted
time: 4ms
memory: 13912kb

input:

4 2
U.
..
.T
S.
8
1 1 b
3 1 r
4 1 r
1 1 r
2 2 b
3 2 b
3 1 b
2 1 r

output:

5

result:

ok single line: '5'

Test #9:

score: 0
Accepted
time: 4ms
memory: 14156kb

input:

2 2
S.
UT
4
1 1 b
1 2 b
2 1 r
1 1 r

output:

-1

result:

ok single line: '-1'

Test #10:

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

input:

3 4
#U.T
#...
.S#.
3
1 2 r
2 2 b
3 1 r

output:

-1

result:

ok single line: '-1'

Test #11:

score: 0
Accepted
time: 4ms
memory: 13908kb

input:

3 5
.U.S.
.#.##
#.T#.
7
1 3 r
1 2 r
1 4 r
1 1 b
1 3 b
2 3 b
3 2 r

output:

-1

result:

ok single line: '-1'

Test #12:

score: 0
Accepted
time: 4ms
memory: 13952kb

input:

4 4
.T.S
#.#.
....
U...
6
3 1 b
1 4 b
2 4 b
3 2 b
4 1 r
3 2 r

output:

-1

result:

ok single line: '-1'

Test #13:

score: 0
Accepted
time: 4ms
memory: 11800kb

input:

5 5
.##T.
##.#.
.#...
##.##
#SU..
6
2 3 b
3 3 r
4 3 b
1 5 b
3 4 r
5 4 r

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

97 97
S...............................................................................................T
.................................................................................................
.................................................................................................
...

output:

130

result:

ok single line: '130'

Test #15:

score: 0
Accepted
time: 4ms
memory: 12196kb

input:

100 94
S............................................................................................T
..............................................................................................
..............................................................................................
...........

output:

126

result:

ok single line: '126'

Test #16:

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

input:

95 92
S..........................................................................................T
............................................................................................
............................................................................................
..................

output:

124

result:

ok single line: '124'

Test #17:

score: 0
Accepted
time: 5ms
memory: 14620kb

input:

92 92
S..........................................................................................T
............................................................................................
............................................................................................
..................

output:

124

result:

ok single line: '124'

Test #18:

score: 0
Accepted
time: 5ms
memory: 12512kb

input:

96 100
S..................................................................................................T
....................................................................................................
..............................................................................................

output:

134

result:

ok single line: '134'

Test #19:

score: 0
Accepted
time: 5ms
memory: 14632kb

input:

92 90
S........................................................................................T
..........................................................................................
..........................................................................................
........................

output:

120

result:

ok single line: '120'

Test #20:

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

input:

96 90
S........................................................................................T
..........................................................................................
..........................................................................................
........................

output:

120

result:

ok single line: '120'

Test #21:

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

input:

92 94
S............................................................................................T
..............................................................................................
..............................................................................................
............

output:

126

result:

ok single line: '126'

Test #22:

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

input:

99 94
S............................................................................................T
..............................................................................................
..............................................................................................
............

output:

126

result:

ok single line: '126'

Test #23:

score: 0
Accepted
time: 3ms
memory: 14892kb

input:

93 91
S.........................................................................................T
...........................................................................................
...........................................................................................
.....................

output:

122

result:

ok single line: '122'

Test #24:

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

input:

50 83
........................#.............................#........#......#.....#......
...........................................#........#................#........#....
....................#.....#........................................................
................................#............

output:

22

result:

ok single line: '22'

Test #25:

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

input:

58 98
.........#.....#...U............#..............#.......#....................##...........#........
.........#........#.....#...#..#........#.#.........#..................#.#........................
.#.##.......#........#......#..#.....#.........#..#.........#...##.........###..##......#..........

output:

-1

result:

ok single line: '-1'

Test #26:

score: 0
Accepted
time: 7ms
memory: 13668kb

input:

80 48
..##.#.........#...#.....#............#.#.#.#...
....#........#.......#...#.##.#.##....#.##.#...#
#......##.#..#.......#.....##..#..#.......##.#.#
.##.#...#.#.#.#.....###...#......#............##
.....#.#.....#.#..##.......##..#...#.#..#..##...
.......#....#.#...##.##.##....#...#......#..####
...

output:

2

result:

ok single line: '2'

Test #27:

score: 0
Accepted
time: 5ms
memory: 14736kb

input:

40 49
#.....................#..................#.......
..................#......#....#..#....#.#.......U
......#.................................#........
.................................................
#.......#.......#..........#.....................
....#.......#.......#............#.............

output:

9

result:

ok single line: '9'

Test #28:

score: 0
Accepted
time: 4ms
memory: 14008kb

input:

25 39
.......................#...............
...................................#...
.......................................
##.......................#.............
..................#.........#..........
..#...................................U
...............................#.......
.................

output:

-1

result:

ok single line: '-1'

Test #29:

score: 0
Accepted
time: 4ms
memory: 14276kb

input:

17 47
..#.....#...#...#........................T.#...
.........................#.........#......#....
.....#..........##..#.......#...#........#.....
......#.......................#................
##...#........#.......##.#.#.......#.##........
...............................................
#..#.....

output:

-1

result:

ok single line: '-1'

Test #30:

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

input:

18 66
...#..#...#..#.#...#U#.#....##...#.#.#.......#.#..........#......#
....##...#...##..##.....#..#.##.#..##...........#....#.....#...#.#
#...##..........##.....#........#...##.#.##............#.#...#.#..
#.#..#..#........#..#....#...#..#.....##..#..#..............#....#
.........#...##.#..#.#.###...

output:

4

result:

ok single line: '4'

Test #31:

score: 0
Accepted
time: 3ms
memory: 16552kb

input:

69 81
.....#..........#.##..U....#..#.S#....#..###..##...........#....##..####.#T.##.##
##........##...##.#.#.##...#.###.#...#....##..#...#..###.....#.................#.
.......##...###..#....#..###.....#..##...#....#..#..#...#.#...#.#....#...##...#.#
#...#...........##..###.#.#.##.#...#.#....#..#.#...

output:

2

result:

ok single line: '2'

Test #32:

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

input:

87 26
.##....#.U.#.#.#......#...
...#...##..#...#.##...#..T
#..........#...#.....#.#..
##.#..##...##.#..#..#.....
................##.....##.
......###..##.#..#..#.....
...#.....#....##..#.......
#.......###..#.....#......
######..##......#.....#...
#.#.#....#.#.........#..#.
.#.....#..###..#......#....

output:

4

result:

ok single line: '4'

Test #33:

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

input:

19 92
.#....#.#.....#.#.........###..S##.#...#..#.#..#...#..####.......#.......#...#.##.##...##...
.......#.#.#.#..#...#..###..#...#..#....#......##........#.#.........#..#.###....#.....#....
......#...#..#.#...#.....##..##......##.###....#...#....#.#.###..#...#####.##..#....#..#.###
.##...##.#.#..#...

output:

2

result:

ok single line: '2'

Test #34:

score: 0
Accepted
time: 3ms
memory: 16116kb

input:

92 96
...#..##.#..##.......#.....#..#.#S#....#.........##...#.#..#...#.......#..#............#..#..#..
...#.#.#.#....#.##....#....#.#....#...#...#....#..##....#..#....#...#..#....#....##....#..#.....
.#...#..#.........#..........#.##.#..#..#.#..#..#.....#.#....#.#.#..........##.......#.#....##..
......

output:

-1

result:

ok single line: '-1'

Test #35:

score: 0
Accepted
time: 5ms
memory: 17680kb

input:

90 90
##....#........#..#..#.#...#...#.#....#.#....##..#.#......#...#......T.#..####........#.#.
..#...............#.#...#...#......#.......#.#..#.#.......#...#.....##....#..##.....#.....
.###.......##.##.........#.#.#..##.##..#........#.#......#......#.#.#..###..##..#.#.....#.
..##......#.........#...

output:

6

result:

ok single line: '6'

Test #36:

score: 0
Accepted
time: 6ms
memory: 16384kb

input:

98 93
..#...........##..........##.#......#....#.....#.......#..#.#.#.......#..................U.#.
..#........#..#..#...#...##.................#.#........#.......##.#..#..#.....#.......#.###.#
...........###..#####.#..##.......#.#........#.#.....#.......#......#....#..#..#.............
#...#.#........

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

96 97
#............#.................#....#.#.#...#....#..###..#.#....#.##...#..#...........#..........
..#.........##........#...#.##....##....###...#.###..#.#..............##.#.....................#.
..#..........#.#.#..#...........#...##............#......##...................#......##....#.....
...

output:

-1

result:

ok single line: '-1'

Test #38:

score: 0
Accepted
time: 8ms
memory: 16020kb

input:

91 94
#...........#.#.##.#..#.....#.#........S.##.......##....#..#........#..#...#..#..#........#U#.
...#.....#..#.....##.#..#.##....#...#.##....#....#......##.#.#............##.......#....#....#
#..#...#..#...#.#..###.#...#....#..##....#....##....#.#.##.........#..#...#.#........#.#.#..##
....##......

output:

4

result:

ok single line: '4'

Test #39:

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

input:

94 91
...........#......#...#.....#..###.....#.......#....##.#....#........#......####.......#...
..#...###...##.......#..#....#..#.###.#....#......#.#..####.##...#...#..##..#.#...###..#...
..#.#.##..#...........#.........#.#.......#...........#.###......#..#....#......#...#......
.#.....##..#.....#...

output:

21

result:

ok single line: '21'

Test #40:

score: 0
Accepted
time: 4ms
memory: 17304kb

input:

90 94
##..........#.#.#.....#.....#..#..#......#.#..##..##....##..#.#.#..#.###.#...#.........T.#....
....#.#.....#.#...............##..#..##.##.#..#....##....###.#.#.#...#..###.........#.##....##
...##.............#..#.....#..#..#.......#....#...###....#.#..#...#.#....#...###..####........
#..##...#...

output:

24

result:

ok single line: '24'

Test #41:

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

input:

93 98
.............#.........#.....U..#......................##.........................................
...........#............#...........................................................###...#.......
....................................................................................#..............

output:

-1

result:

ok single line: '-1'

Test #42:

score: 0
Accepted
time: 10ms
memory: 15068kb

input:

96 100
..........#........#..#...#..#.........#....#....#.#.....##......##....##............#.............#
.......#.#..#.#.#..#....................#..............##.....#.........#...#...#.....#.....#.....#.
##.....##.#.###...#...#.#.............###.#.......#.#................#........#........##.....

output:

12

result:

ok single line: '12'

Test #43:

score: 0
Accepted
time: 3ms
memory: 17120kb

input:

100 99
................#..#............T.....#.....#.....#............#.#.....U.#..#.....#..........#.....
.................................#.#...............................................................
............#..........#..#..#.........#...................#............................#.......

output:

100

result:

ok single line: '100'

Test #44:

score: -100
Wrong Answer
time: 1ms
memory: 9816kb

input:

13 22
..#...#U#......#....##
......##.............#
......#....#...#.....#
.........#..#.........
...................#..
......###.........#..#
....#..............#.T
.#..#...#.............
#.....#.....##...#....
.#.........#.##.......
......#..#............
.#.....#...#...#......
..S..#.#.............

output:

-1

result:

wrong answer 1st lines differ - expected: '0', found: '-1'