QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153433#5472. Secure the Top Secretntu_vjudge_2AC ✓13ms8888kbC++176.6kb2023-08-30 01:50:332023-08-30 01:50:35

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3752kb

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: 1ms
memory: 3820kb

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: 1ms
memory: 3780kb

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: 1ms
memory: 3616kb

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: 1ms
memory: 3536kb

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: 0ms
memory: 3604kb

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: 3600kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #8:

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

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: 0ms
memory: 3612kb

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: 3608kb

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: 1ms
memory: 3616kb

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: 1ms
memory: 3784kb

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: 0ms
memory: 3600kb

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: 4332kb

input:

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

output:

130

result:

ok single line: '130'

Test #15:

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

input:

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

output:

126

result:

ok single line: '126'

Test #16:

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

input:

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

output:

124

result:

ok single line: '124'

Test #17:

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

input:

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

output:

124

result:

ok single line: '124'

Test #18:

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

input:

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

output:

134

result:

ok single line: '134'

Test #19:

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

input:

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

output:

120

result:

ok single line: '120'

Test #20:

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

input:

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

output:

120

result:

ok single line: '120'

Test #21:

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

input:

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

output:

126

result:

ok single line: '126'

Test #22:

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

input:

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

output:

126

result:

ok single line: '126'

Test #23:

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

input:

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

output:

122

result:

ok single line: '122'

Test #24:

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

input:

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

output:

22

result:

ok single line: '22'

Test #25:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #26:

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

input:

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

output:

2

result:

ok single line: '2'

Test #27:

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

input:

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

output:

9

result:

ok single line: '9'

Test #28:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #30:

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

input:

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

output:

4

result:

ok single line: '4'

Test #31:

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

input:

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

output:

2

result:

ok single line: '2'

Test #32:

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

input:

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

output:

4

result:

ok single line: '4'

Test #33:

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

input:

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

output:

2

result:

ok single line: '2'

Test #34:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #35:

score: 0
Accepted
time: 11ms
memory: 7788kb

input:

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

output:

6

result:

ok single line: '6'

Test #36:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #38:

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

input:

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

output:

4

result:

ok single line: '4'

Test #39:

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

input:

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

output:

21

result:

ok single line: '21'

Test #40:

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

input:

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

output:

24

result:

ok single line: '24'

Test #41:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #42:

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

input:

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

output:

12

result:

ok single line: '12'

Test #43:

score: 0
Accepted
time: 9ms
memory: 6812kb

input:

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

output:

100

result:

ok single line: '100'

Test #44:

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

input:

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

output:

0

result:

ok single line: '0'

Test #45:

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

input:

84 35
...#.#.#.......###..#......##.###..
...#....##.#..##......###.#..#.##..
...###.....#..###.#..#.#..#...#...#
#...###.#..#..#....#...#.#.#.....#.
###...##......#.##.#.....#...#.#..#
...#.#...###......#.....#....#....#
#.#..##.##.###...#..###....##.##...
###..#.#........#...#.#.##.#.#.....
...#.....

output:

0

result:

ok single line: '0'

Test #46:

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

input:

3 82
#..#.#.....#........#.##........####...#...#..##...#......#..S.##..#..#..#..##..#.
...#..##.............#...#..#....#...............#.#....##....#...................
.#..............U................#...#...##.......#..#...T.#..#......#...#......#.
250
2 73 b
2 19 r
3 11 r
2 13 r
2 35 b
3 64 r
...

output:

0

result:

ok single line: '0'

Test #47:

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

input:

85 67
...##....##..#..#....##..##S.##...#....#.#............#............
.......#.#..#....#..#..#.#...##..##.#...#.#.#...#......#.....##..#.
..#.....#.....#.#.......#.....#.......#..#.###..#.........#........
##.#.#.#.#.###.#..........##....#.....#.#..##.#...........#...###.#
...........#.......#.....

output:

0

result:

ok single line: '0'

Test #48:

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

input:

42 30
##.....##.#.#T.#.#.#.#....#.#.
..#.......##...#.#.#...#......
#.........#...#.##....#..#....
.....#..#....#..#...##...####.
#.......###...#..#......#..#..
...#.....#......#..#......#.##
##.#.#.#..#...#.......####....
....#...##.....#....#.#.#.....
........#..#.#......#....#.#..
.#.##.#...###.....

output:

0

result:

ok single line: '0'

Test #49:

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

input:

62 62
..........##...#.#.............#.#..........#.................
...............#.#............#..........................#....
...................#.........................##...............
........#............#..................#................#....
..........................#..#.......##......

output:

8

result:

ok single line: '8'

Test #50:

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

input:

89 74
...#....#.#....#...........#..#T.#....................##.U.............##.
...##.....#......##......................#....#.#..#....#..#........##....
...#.##............#...#.........#........#.#..........##.#..#............
.#.......#.....#.....#..#..............##.#................#............

output:

4

result:

ok single line: '4'

Test #51:

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

input:

100 37
.....................#..#.........#..
.............#........#........#.....
...........#.........................
..##..#.....#.............#..........
............#..................#.....
#..#................##...#...........
..#...........#...#..................
..................#.#.....#...

output:

6

result:

ok single line: '6'

Test #52:

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

input:

44 89
...#.#.#...##.#.#.....#..##..#.#......##.........#..##....#.....##....##.#.........#..#..
##....##.#...........#...#..##.#....#...#.#.#......#........#..#..........#.......##....#
....#..#...#.#......#.#...###.#......#....#.#.#......#...##..............##.#.##...#..#..
.#.....###.#..#...#..#.....

output:

4

result:

ok single line: '4'

Test #53:

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

input:

68 17
##.....#....#....
.#.##...#...#...#
...#....#....##..
..#...#........#.
..#..####.#...##.
.....###.........
.#.........#..#.#
....#.#.#.#.....#
...#.....#.......
#..#.###...####..
..##.##....#.#...
##.....#.#.....#.
....#....#......#
..##.............
.....#.........#.
....#...........#
..##.....

output:

6

result:

ok single line: '6'

Test #54:

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

input:

16 23
..#..##.#U.#...#....#.#
...#...##.##.#...##...#
...#.#..#..##.#..#.#...
...#..#.#.#..#....#...#
##..#..#........#......
.......#.#.#........#..
.#.....#...#..#.#......
........#..###.....###.
.##.......#.###..##.#..
.....#..######......#..
#..#....#....#.#....#.#
....#.#..#....##....##.
.#.#.....

output:

-1

result:

ok single line: '-1'

Test #55:

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

input:

43 67
.............#....#.............................S.#............#...
..........#.................#.............#........................
................................#................................#.
.........................#..........#...........#..................
....#....................

output:

-1

result:

ok single line: '-1'

Test #56:

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

input:

79 22
.#......#..#...#.#...#
............#.........
.###.......#.#..#....#
..#..#...........##...
......#.....###....#.#
#.......#..#........#.
.....#.....#..........
......#.#.#.......#...
....#......##..#....#.
...#...#......##......
.....#...#.#..###.....
.....###.......#......
#...........#..#.....

output:

-1

result:

ok single line: '-1'

Test #57:

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

input:

9 18
...#...#....#....#
.........##.......
..#.....#.#..###.U
...#..#..####...#T
.#.###.##.......#.
......#....####.#.
#....#....##.#..##
S............#.#..
###..#....#...#..#
0

output:

-1

result:

ok single line: '-1'

Test #58:

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

input:

40 72
#...#...#......#.#.#....#.##..##.#..##.#####..#.##...###.#.####..##.....
.###.#..#.......#..#..#..#.#.#....##.....#..###.#..#.##..#.#.#....#....#
..#.#..#..#..#....#..####....#.#....##............#..#...##..#.#.#..#..#
####..#.##.....#..#........#.#......#...#..###.......##..#..............
.....

output:

-1

result:

ok single line: '-1'

Test #59:

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

input:

100 100
....................................................................................................
.........#..........................................................................................
.........................................................................................#...

output:

-1

result:

ok single line: '-1'

Test #60:

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

input:

100 100
...........#..........................##...#....#.#..............##.....#.#..........#.......#...#..
.....#.....#...#...........#....##............#.....##................#..##.......###...#...........
..#......##.....#.#.#.....#...#.#.....#..#........................#.#.#........#.#..###..#...

output:

-1

result:

ok single line: '-1'

Test #61:

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

input:

100 100
................##.....#........................................#...##.......#...#..S...##.......U..
...#.....#..................................#.............###......................#................
.........#....#......#.....................................#......#.............#............

output:

-1

result:

ok single line: '-1'

Test #62:

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

input:

100 100
..........................#........#..............#.........##.#.#....#....#...#....................
.......................#.................#..##..................#.....................#..#.#........
...........#....................#....................#....#...................#..............

output:

17

result:

ok single line: '17'

Test #63:

score: 0
Accepted
time: 9ms
memory: 6520kb

input:

100 100
.......................................U............................................................
............................................................................##......................
.............................................................#...............................

output:

42

result:

ok single line: '42'

Test #64:

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

input:

100 100
....................................................................................................
....................................................................................................
.............................................................................................

output:

10

result:

ok single line: '10'

Test #65:

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

input:

100 100
#........................................#.......................#..................................
..............................................#......#..................#......................#....
....#...........#................#......#....................................................

output:

10

result:

ok single line: '10'

Test #66:

score: 0
Accepted
time: 13ms
memory: 8888kb

input:

100 100
...##.##......##.........#....###...#.#..#.#..##..###..#..#.#..#...#.#.........#.#.#....#.#..#.#...T
...#.#..##.#..#.#.................#..............#.#.....#........##....#....#..........#..#.#......
#.#.....#...#...#..##...................#.#..#..##.#......#..#........#.#....#...#...#.......

output:

3

result:

ok single line: '3'

Test #67:

score: 0
Accepted
time: 9ms
memory: 7988kb

input:

100 100
.............................#.......................#..............................................
...............................................................................#....................
......#...###.......................................................##............#..........

output:

6

result:

ok single line: '6'

Test #68:

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

input:

100 100
.......#......................#.....#.............#.....T.......#.............#.....................
.....................................#..............................#...................#.......##..
................................#....#........................#..............................

output:

7

result:

ok single line: '7'

Test #69:

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

input:

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

output:

9902

result:

ok single line: '9902'

Test #70:

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

input:

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

output:

9506

result:

ok single line: '9506'

Test #71:

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

input:

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

output:

2280

result:

ok single line: '2280'

Test #72:

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

input:

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

output:

1470

result:

ok single line: '1470'

Test #73:

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

input:

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

output:

102

result:

ok single line: '102'

Test #74:

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

input:

2 3
STU
###
2
1 1 r
1 2 r

output:

-1

result:

ok single line: '-1'

Test #75:

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

input:

2 4
ST.U
####
3
1 1 r
1 2 r
1 3 r

output:

2

result:

ok single line: '2'

Test #76:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #77:

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

input:

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

output:

21

result:

ok single line: '21'

Test #78:

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

input:

10 10
..........
..........
..........
..........
..........
.....#....
##....#...
U...#..#..
####......
ST........
25
8 9 b
7 9 r
9 8 r
6 4 r
10 1 r
3 5 b
6 9 b
9 6 b
7 9 b
4 4 r
9 8 b
4 6 r
9 5 r
8 10 b
6 4 b
5 4 r
9 10 b
7 3 r
5 6 r
6 8 b
7 4 b
8 9 r
9 9 r
3 6 b
9 7 b

output:

21

result:

ok single line: '21'