QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#394414#7751. Palindrome Pathy0y68TL 94ms4012kbC++145.3kb2024-04-20 14:29:202024-04-20 14:29:20

詳細信息

Test #1:

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

input:

2 2
11
11
1 1 2 2

output:

RDDURLDDURDDRUDDLRUDDR

result:

ok Valid Solution (Length = 22).

Test #2:

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

input:

2 2
10
01
1 1 2 2

output:

-1

result:

ok No Solution.

Test #3:

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

input:

1 1
1
1 1 1 1

output:


result:

ok Valid Solution (Length = 0).

Test #4:

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

input:

5 4
1111
1111
1111
1111
1111
4 2 4 2

output:

LLRRLLRRRUDDDUDDUUDDDUUUDDDUUUUUDUDDUDDRLUDDDUDDUUDDDUUUDDDUUUUUDUDDUDDRLLRLLUDDDUDDUUDDDUUUDDDUUUUUDUDDUDDLRUDDDUDDUUDDDUUUDDDUUUUUDUDDUDDDDUDDUDUUUUUDDDUUUDDDUUDDUDDDURLDDUDDUDUUUUUDDDUUUDDDUUDDUDDDULLRLLRDDUDDUDUUUUUDDDUUUDDDUUDDUDDDULRDDUDDUDUUUUUDDDUUUDDDUUDDUDDDURRRLLRRLL

result:

ok Valid Solution (Length = 278).

Test #5:

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

input:

5 5
11111
10101
11111
10101
11111
1 4 5 5

output:

RDDRLRDDRLRDUDDUUDDDUUUDDDDUUUURLRRLLRRRLLLRRRRLLLLDDDDDUDDUUDDDUUUDDDDUUUURRDDRRRLLLRDDRRRLLLRDUDDUUDDDUUUDDDDUUUURRDDRLRRLLRRRLLLRRRRLLLLDDRRRRRRRRDDLLLLRRRRLLLRRRLLRRLRDDRRUUUUDDDDUUUDDDUUDDUDRLLLRRRDDRLLLRRRDDRRUUUUDDDDUUUDDDUUDDUDDDDDLLLLRRRRLLLRRRLLRRLRUUUUDDDDUUUDDDUUDDUDRLRDDRLRDDR

result:

ok Valid Solution (Length = 290).

Test #6:

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

input:

5 3
111
100
111
001
111
4 3 3 2

output:

DRLRLLLRLRRUURLRLLUULRLRRRLRLLDDLRLRRDURLLRUDRRLRLDDLLRLRRRLRLUULLRLRUURRLRLLLRLRD

result:

ok Valid Solution (Length = 82).

Test #7:

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

input:

5 4
1001
1101
1111
0011
0010
2 2 1 1

output:

LUUDDUUUDRUDRRUUDDDUUUUDUUDDLUDUUDDUULULUULULUUDDUUDULDDUUDUUUUDDDUURRDURDUUUDDUUL

result:

ok Valid Solution (Length = 82).

Test #8:

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

input:

5 3
101
111
100
111
100
4 1 2 2

output:

LRLRRRLRLLDUUULRLRRUDRLRLLUDDDUULRRLUUDDDULLRLRDURRLRLUUUDLLRLRRRLRL

result:

ok Valid Solution (Length = 68).

Test #9:

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

input:

5 5
01110
10110
11110
11011
11100
2 4 5 1

output:

LDLLDDDUDDUUDDDUUUDLRDDLLRRLDUDDUULLRRDUDDUULLRDLRDDLRLDUDDUUDDDUUUDLDLLDLRDLLDRLDLLDLDUUUDDDUUDDUDLRLDDRLDRLLUUDDUDRRLLUUDDUDLRRLLDDRLDUUUDDDUUDDUDDDLLDL

result:

ok Valid Solution (Length = 154).

Test #10:

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

input:

5 3
011
111
110
111
011
3 1 2 1

output:

LRUUDDDLLRRUDULUUDDDUUULLRRUUDLUUDUUDDLUUDDUUUDLRULLURLDUUUDDUULDDUUDUULDUURRLLUUUDDDUULUDURRLLDDDUURL

result:

ok Valid Solution (Length = 102).

Test #11:

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

input:

4 5
11111
11111
11111
11111
3 2 1 3

output:

LLRRLLRRRLLRRRUUUDDDUUUUDUUDDRLUUUDDDUUUUDUUDDRRLLUUUDDDUUUUDUUDDRRLLLRRLLLUUUDDDUUUUDUUDDLRUUUDDDUUUUDUUDDLLRRLLRRRLLRRRUUUDDDRLRRLLRRLLLRRLLLUULRLLRRLLRRRLLRRRURLRRLLLLRRLRURRRLLRRRLLRRLLRLUULLLRRLLLRRLLRRLRDDDUUURRRLLRRRLLRRLLDDUUDUUUUDDDUUURLDDUUDUUUUDDDUUULLLRRLLLRRDDUUDUUUUDDDUUULLRRDDUUDUUUUD...

result:

ok Valid Solution (Length = 336).

Test #12:

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

input:

5 5
11111
10101
11111
10101
11111
2 5 1 1

output:

UUDDLLLLUUUDDDUUUUDDDDUUUUUDDLRLLRRUUUDDDUUUUDDDDLLLRRUUUUUDDLLLRRRLLLLRRRRUUUDDDUUUUDDDDLLLLLRRRRUUUULLLLLRLLRRLLLRRRLLLLRRRRUDUUDDLLLLUUUULLLLDDUUDURRRRLLLLRRRLLLRRLLRLLLLLUUUURRRRLLLLLDDDDUUUUDDDUUURRRRLLLLRRRLLLDDUUUUURRLLLDDDDUUUUDDDUUURRLLRLDDUUUUUDDDDUUUUDDDUUULLLLDDUU

result:

ok Valid Solution (Length = 276).

Test #13:

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

input:

4 5
11111
10000
11111
00001
1 3 4 5

output:

RRLLLLDDRRRRDDULLLLDUDUURRLLDDRRRRDDRRRRDDLLRRUUDUDLLLLUDDRRRRDDLLLLRR

result:

ok Valid Solution (Length = 70).

Test #14:

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

input:

3 5
10100
00010
00111
1 3 1 1

output:

-1

result:

ok No Solution.

Test #15:

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

input:

4 5
10001
11111
11100
11111
4 5 3 1

output:

LLLLDUDDUUDDUUUUDUDDUDDLRDUDDUUUDUDDLLRRDUDDUULLRRRLLRRRDUUDLLUDUDDLLRRRLLRRRLLLLDUUDLLLLRRRLLRRRLLDDUDULLDUUDRRRLLRRRLLUUDDUDRRLLDDUDUUUDDUDRLDDUDDUDUUUUDDUUDDUDLLLL

result:

ok Valid Solution (Length = 166).

Test #16:

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

input:

3 5
11111
10100
11111
1 2 3 5

output:

RRRRLRRLLDDRRRLRRLLRRRLLLRUURRRLLLRRRRLLLLDDUURRDDRRRRDDRRUUDDLLLLRRRRLLLRRRUURLLLRRRLLRRLRRRDDLLRRLRRRR

result:

ok Valid Solution (Length = 104).

Test #17:

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

input:

4 5
01110
10101
11011
10111
1 3 2 3

output:

-1

result:

ok No Solution.

Test #18:

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

input:

5 5
11111
11111
11111
11111
11111
1 3 5 2

output:

LLLRRRLLLRRRRDDDDDUDDUUDDDUUUDDDDUUUURLDDDDDUDDUUDDDUUUDDDDUUUURLLRLLRLLDDDDDUDDUUDDDUUUDDDDUUUULRDDDDDUDDUUDDDUUUDDDDUUUULLRRDDDDDUDDUUDDDUUUDDDDUUUULLLRRRLLLRRRRDRLRLLRLLRLLDLRLLRRLLLRRRLLLRRRRDRLRLLRLLRLLDLRRLDLLRLLRLLRLRDRRRRLLLRRRLLLRRLLRLDLLRLLRLLRLRDRRRRLLLRRRLLLUUUUDDDDUUUDDDUUDDUDDDDDRRLLUU...

result:

ok Valid Solution (Length = 420).

Test #19:

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

input:

5 5
11111
10101
11111
10101
11111
5 1 2 3

output:

RRRRDUDUUDUUDUUUDUUDDUUUDDDUUUDDDDLLDUDUURLDUUDUURLUDUUDDUUUDDDUUUDDDDLLDUDUURLDUUDUURLUDUUDDUUUDDDUUUDDDDRRRRDUDUULLLLDUUDUURRUDDURRUUDUUDLLLLUUDUDRRRRDDDDUUUDDDUUUDDUUDULRUUDUUDLRUUDUDLLDDDDUUUDDDUUUDDUUDULRUUDUUDLRUUDUDLLDDDDUUUDDDUUUDDUUDUUUDUUDUUDUDRRRR

result:

ok Valid Solution (Length = 258).

Test #20:

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

input:

5 5
11111
10000
11111
00001
11111
4 5 5 3

output:

DRLRRLLRRLLLRRLLLLRLLRRLLRRRLLRRRUURLRRLLRRLLLRRLLLUULRLLRRLLRRRLLRRRRLRRLLRRLLLRRLLLDDLRLLRRLLRRRLLRRRDDRLRRLLLLRRLRDDRRRLLRRRLLRRLLRLDDLLLRRLLLRRLLRRLRRRRLLRRRLLRRLLRLUULLLRRLLLRRLLRRLRUURRRLLRRRLLRRLLRLLLLRRLLLRRLLRRLRD

result:

ok Valid Solution (Length = 222).

Test #21:

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

input:

5 5
01010
10101
10101
11001
10011
4 1 5 4

output:

-1

result:

ok No Solution.

Test #22:

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

input:

5 5
10101
11111
10101
11111
11111
3 1 2 4

output:

DLRLRRLRRLRRDUUDRLDURRLLDUUDRRRLLLDURRRLLLLDUUULRLRRLRRLRRUDRLRRLLUDRRRLLLRRRLLLLUDDDLRLRRLRRLRRUURLLRUURRLRRLRRLRLDDDULLLLRRRLLLRRRDULLRRLRDURRLRRLRRLRLUUUDLLLLRRRUDLLLRRRDUUDLLRRUDLRDUUDRRLRRLRRLRLD

result:

ok Valid Solution (Length = 200).

Test #23:

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

input:

5 5
00001
11111
01110
01111
01111
1 5 5 2

output:

DLLLLLRDDDDUDDUUDDDUUULLRRDDDDUDDUUDDDUUULLLRRRDDLLLRRRDDULDDUDDUUDDDUUULLLRRRRDUDLLLDLRLLRRDLLLRRRDLLLLLLDRRRLLLDRRLLRLDLLLDUDRRRRLLLUUUDDDUUDDUDDLUDDRRRLLLDDRRRLLLUUUDDDUUDDUDDDDRRLLUUUDDDUUDDUDDDDRLLLLLD

result:

ok Valid Solution (Length = 206).

Test #24:

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

input:

5 5
01011
10111
11011
10101
01110
4 1 2 3

output:

-1

result:

ok No Solution.

Test #25:

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

input:

10 8
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111
7 7 3 6

output:

LLRRRUUUUUUUDDDDDDDUUUUUUUDDDDDDDDUUUUUUUDDDDDDDDDUDDUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUUDUUDDUUUDDDUUUUDDDDUUUUUDDDDDUUUUUUDDDDDDRLRRLLRRRLLLRRRRLLLLRRRRRLLLLLRRRRRLLLLLLRRRRRLLLLLLUUUUUUUDDDDDDDUUUUUUUDDDDDDDDUUUUUUUDDDDDDDDDUDDUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUUDUUDDUUUDDDUUUUDDDDUUUUUDDDDDU...

result:

ok Valid Solution (Length = 2630).

Test #26:

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

input:

10 6
111111
101010
111111
101010
111111
101010
111111
101010
111111
101010
1 6 2 3

output:

LLLLLUDUUDDUUUDDDUUUUDDDDUUUUUDDDDDUUUUUUDDDDDDUUUUUUUDDDDDDDUUUUUUUUDDDDDDDDUUUUUUUUDDDDDDDDDDUDUUDUUDUUDUUDUUDUUDUUDUURRUDUUDDLRUUUDDDUUUUDDDDLRUUUUUDDDDDUUUUUUDDDDDDLRUUUUUUUDDDDDDDUUUUUUUUDDDDDDDDLRUUUUUUUUDDDDDDDDDDUDUUDUUDUUDUUDUUDUUDUUDUURRUDUUDDRLLRUUUDDDUUUUDDDDRLLRUUUUUDDDDDUUUUUUDDDDDDRLL...

result:

ok Valid Solution (Length = 790).

Test #27:

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

input:

10 10
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
5 5 5 2

output:

LLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRUURLRLLRLLRLLRLLRLLRLLRLLRLLUULRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRRLRLLRLLRLLRLLRLLRLLRLLRLLDDLRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRR...

result:

ok Valid Solution (Length = 1204).

Test #28:

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

input:

10 10
1010110101
0000011010
1001001001
0011111000
1000111100
1011101001
1100110011
0110001011
0011111000
0101011101
7 5 4 3

output:

-1

result:

ok No Solution.

Test #29:

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

input:

10 6
100100
111111
100001
111111
101111
111111
101010
111111
111100
111111
6 5 7 3

output:

RDUDDUUDDDUUUDDDUUUULLLLRRDUUDRRUDUUDDUUUDDDUUUDDDDLLLLLUUUDDDDUUUDDDDUUUDDDDUUUDDDDDUDDUUDDDUUUDDDUUUUDDDUUUUDDDUUUUDDDUUUUDDDUUUUDDDUUUUUDUUDDUUUDDDUUUDDDDUUUDDDDRRUUUDDDUUUDDDDLUDUUDDDUDDUURUUUDDDDUUUDDDDDUDDUUDDDUUUDDDUUUUDDDUUUUDDDUUUULRUDUUDDRDUDDUUUDUUDDRUUUDDDUUUDDDDRLLUDUUDDRRLLDUDDUURDUDDU...

result:

ok Valid Solution (Length = 708).

Test #30:

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

input:

10 8
11111110
11110111
01111111
11111101
11011101
11111111
11111011
11011101
11001111
11111110
7 1 2 1

output:

LRLLRRLLLRRRLLLRRRRDLLRRDLLRRLLLRRRDUDLDDULDDUDUULDDDUDUUDUUDUULLLRRRRLLLRRRRLLLRRRRDDUUDUUDUUDUUDUUDDDDLDDULDUDUUDUULLLRRRRDUDUUDDLDUUDUUDDDDDLDUUDUUDUUDDDDLDDUDUUDUUDUUDUUDUUDUULLLRRRRLDDDDDDLDUDLDDDLLRRLLLRRRLLDUDUUDUUDUUDUUDUULLRRDUDUUDUUDDDLDUUDUULDUDLRDUUDDDDDDLDDDDUDUUDUUDUUDUUDUUDDDLRLLRRLLL...

result:

ok Valid Solution (Length = 752).

Test #31:

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

input:

10 10
1111011101
1110111110
1111011111
1011101111
0101010111
1110111111
0111010111
1011111011
0111010101
1011111110
2 6 7 4

output:

-1

result:

ok No Solution.

Test #32:

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

input:

8 10
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
8 10 6 10

output:

RLRRLLRRRLLLRRRRLLLLRRRRRLLLLLRRRRRRLLLLLLRRRRRRRLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRLLLLLLLLLDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDUUUUUUDDDDDUUUUUUUDUUDDUUDDDUUDDDUUDDDUUDDDUUDDDRDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDUUUUUUDDDDDUUUUUUUDUUDDUUDDDUUDDDUUDDDUUDDDUUDDDRDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDUUUUUUD...

result:

ok Valid Solution (Length = 2068).

Test #33:

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

input:

10 10
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
3 5 9 1

output:

LLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLLRRRRRRRRRLUDDUDDLLLLLLLLLRRRRRRRRRLUDDUDDLLLLLLLLLRRRRRRRRRLUDDUDDLLLLLLLLLRRRRRRRRRLUDDDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDDUUUUUUDDDDDDDUUUUUUUDDDDDDDDUUUUUUUUDDDDDDDDUUUUUUUUULLLLLLLLLRRRRRRRRRLUDUDDLLUDDUDDLLLLLLLRRRRRRRLUDDUDDLLLLLLLRR...

result:

ok Valid Solution (Length = 2136).

Test #34:

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

input:

10 10
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
5 4 7 2

output:

LLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRUURLRLLRLLRLLRLLRLLRLLRLLRLLUULRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRRLRLLRLLRLLRLLRLLRLLRLLRLLDDLRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLL...

result:

ok Valid Solution (Length = 1212).

Test #35:

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

input:

9 10
1111001000
1110010111
0001001000
0101000101
1101000001
0111100110
0010010000
0001001000
1011001101
2 8 5 2

output:

-1

result:

ok No Solution.

Test #36:

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

input:

5 10
1001011101
1111111111
1000011001
1111111111
1101110010
4 3 4 7

output:

LLLRRRLLLRRRRLLLRRRRLLLRRRRLLLRRRRLLLRRRRLLLRRRRDUDDUUDDDUUUDDDRLDDURRLLRRRLLLDUDDUULLLRRRRLLLRRRRRRLLDUDRRRLLLDDDUUUDDDRRRRLLLLDDUDDUUDDDUUURRRRRLLLLLRRRRRRLLLLLLDUDLLLRRRRLLLRRRRDDDUUUUDDDRRRRRLLLLLDDURRRRRRLLLLLLDDURRRRRRLLLLLLLRRRRRRLLLLLLLRRRRRRLLLLLLLDDUDDUUDDDUUULRLLRRRRRRRRLLLLLLLRRRRRRLLLLL...

result:

ok Valid Solution (Length = 696).

Test #37:

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

input:

7 10
1111111001
1111101110
1111011111
1101011101
1111011111
1111001011
1111111011
7 10 7 2

output:

-1

result:

ok No Solution.

Test #38:

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

input:

9 10
0101011101
1111111111
0101111111
1111111111
1111110101
1011111111
1101111101
1111111011
1101011111
3 7 7 10

output:

RRRUUDDDUUDDDUUDDDUUDDDUUDDDLUDDURUUDDDDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDDUUUUUUDDDDDDUUUUUUUDDDDDDUUUUUUUUDUUDDLUUDDDUDDUUUDLUUDDDUUDDDUUDDDRLLUDUUDDUUDDDRLDUDDUUDDDUUURUUDDDDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDDUUUUUUUDUUDDLLLLUUDDDLLLUDUUDDUUDDDRLUUDDDUUDDDDUDDUUDDDUUUDDDDUUUUDDDDDUUUUURUUDDDDUDDU...

result:

ok Valid Solution (Length = 1362).

Test #39:

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

input:

10 10
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
1111111111
9 5 3 2

output:

LLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRRUUUUUUUDDDDDDDDDUDDUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUUDUUDDUUUDDDUUUUDDDDUUUUUDDDDDUUUUUUDDDDDDUUUUUUUDDDDDDDUUUUUUUDDDDDDDDRLUUUUUUUDDDDDDDDDUDDUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUDDUUUUDUUDDUUUDDDUUUUDDDDUUUUUDDDDDUUUUUUDDDDDDUUUU...

result:

ok Valid Solution (Length = 3736).

Test #40:

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

input:

10 10
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
1111111111
1010101010
2 1 1 3

output:

UUDDLRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLLRRRRRRLLLLLLLRRRRRRRLLLLLLLRRRRRRRRLLLLLLLRRRRRRRRRLUUUDDDUUUUDDDDLLLLLLLRRRRRRRRRLUUUUUDDDDDUUUUUUDDDDDDLLLLLLLRRRRRRRRRLUUUUUUUDDDDDDDUUUUUUUUDDDDDDDDLLLLLLLRRRRRRRRRLUUUUUUUUUDDDDDDDDDUUUUUUUUUUDDRRLLRRLLLUUUDDDUUUUDDDDLLLLLLLRRRRRRRRRLLLUUUUUDDDDDUUUUUUDDD...

result:

ok Valid Solution (Length = 2100).

Test #41:

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

input:

10 10
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
1111111111
0000000001
1111111111
1000000000
7 4 3 5

output:

LLLLRRRRLLLLLRRRRRLLLLLRRRRRRLLLLLRRRRRRLLLLLRRRRRRLLLLLRRRRRRDDRLRRLLRRRLLLRRRRLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLDULRLLRRLLLRRRLLLLRRRRLLLLLRRRRRLLLLLRRRRRRLLLLLRRRRRRLLLLLRRRRRRLLLLLRRRRRRUURLRRLLRRRLLLRRRRLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLRRRRLLLLLUULRLLRRLLLRRRLLLLRRRRLLLLLR...

result:

ok Valid Solution (Length = 1694).

Test #42:

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

input:

10 10
1110000101
1100110001
1011011001
0000000111
0010010111
0100111011
1110010011
1100111111
0110001110
0100000101
9 9 6 10

output:

-1

result:

ok No Solution.

Test #43:

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

input:

10 10
1110111011
1111111111
1110110000
1111111111
1010011100
1111111111
1111001110
1111111111
1001010011
1111111111
6 9 2 9

output:

LRRRLRRLLRRRLLLRRRRLLLLRRRRRLLLLLRRRRRRLLLLLLRRRRRRRLLLLLLLRRRRRRRRLLLLLLLLRRRRRRRRLLLLLLLLLDDDDDUDUUDUUDUUDUUDUUDUUDUUDUUDDDDDLRDDDUDUULRRDDDUDUUDUUDUURRRRRRRRLLLLLLLLDUDUUDUUDDDLRRDUUDUUDUUDDDDDLRRDDDDRRRRRRRLLLLLLLRRRRRRRRLLLLLLLLLRRLRRDUDUUDUUDUULRRLRRDUDUURRRRRLLLLLRRRRRRLLLLLLLRRDUDUURRRRRRLLL...

result:

ok Valid Solution (Length = 1270).

Test #44:

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

input:

10 10
1111110011
1011111110
0111011111
1101101101
1111111110
1110111101
1011011111
1111111101
1011111101
1111111011
7 3 5 5

output:

LRUDLLLLRRRRLLLLRRRRRLLLLRRRRRLLLLRRRRRUDDDUDUULLLRRRLLLLRRRRUDDUDDUDDRLLRDUDUUDUUDUUUDRLRRLLDUUUDDUDDRLUDDUDDDUDUUDUUDUUUDDUDDRRLLUDDUDDDUDUUDUUDUUUDDUDDRRRLLLUDUDDDUDUURRRRLLLLUDDUDDDUDUUDUURLUDDRRRRLLLLLRRRRLLLLLUDDUDDDUDUUDUUUDDLRLLRRUDDUDDRRRRLLLLLLLRRDUDUUDUUDUURLRRLLDUUDUUUDUDDLRDUDUUDUULRDUD...

result:

ok Valid Solution (Length = 1444).

Test #45:

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

input:

10 10
1101011101
1110111011
0101110101
1111101011
1111111111
1010111010
0111111101
1111101011
0111111101
1011101111
3 8 2 2

output:

-1

result:

ok No Solution.

Test #46:

score: 0
Accepted
time: 94ms
memory: 3780kb

input:

20 12
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
111111111111
16 8 13 12

output:

RRRRUUUUUUUDDDDDDDDUUUUUUUDDDDDDDDUUUUUUUDDDDDDDDUUUUUUUDDDDDDDDDUDDUUDDDUUUDDDDUUUUDDDDDUUUUUDDDDDDUUUUUUDDDDDDDUUUUUUUDDDDDDDDUUUUUUUUDDDDDDDDDUUUUUUUUUDDDDDDDDDDUUUUUUUUUUDDDDDDDDDDDUUUUUUUUUUUDDDDDDDDDDDDUUUUUUUUUUUUDDDDDDDDDDDDUUUUUUUUUUUUUDDDDDDDDDDDDUUUUUUUUUUUUUDDDDDDDDDDDDUUUUUUUUUUUUUDDDDD...

result:

ok Valid Solution (Length = 14592).

Test #47:

score: -100
Time Limit Exceeded

input:

20 17
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
11111111111111111
10101010101010101
111111...

output:


result: