QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#718853#8981. Kangaroo PuzzleKobicGendAC ✓5ms5084kbC++232.3kb2024-11-06 21:37:092024-11-06 21:37:10

Judging History

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

  • [2024-11-06 21:37:10]
  • 评测
  • 测评结果:AC
  • 用时:5ms
  • 内存:5084kb
  • [2024-11-06 21:37:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int dx[4] = { +1, 0, -1, 0 };
const int dy[4] = { 0, +1, 0, -1 };
const string dirs = "DRUL";

char s[30][30];

int mp[30][30];
int E[410][4];

int dis[410][410];
int pre[410][410];

int main() {
	int n, m;
	cin >> n >> m;
	for (int x = 0; x < n; ++x) {
		cin >> s[x];
	}

	int V = 0;
	memset(mp, ~0, sizeof(mp));  // -1
	for (int x = 0; x < n; ++x) {
		for (int y = 0; y < m; ++y) {
			if (s[x][y] == '1') {
				mp[x][y] = V++;
			}
		}
	}
	for (int x = 0; x < n; ++x) {
		for (int y = 0; y < m; ++y) {
			int u = mp[x][y];
            if (u == -1) continue;
            for (int i = 0; i < 4; ++i) {
                auto [nx, ny] = pair(x + dx[i], y + dy[i]);
                E[u][i] = (0 <= nx && nx < n && 0 <= ny && ny < m && ~mp[nx][ny]) ? mp[nx][ny] : u;
            }
		}
	}

	queue<pair<int, int>> Q;
	memset(dis, ~0, sizeof(dis));
	memset(pre, ~0, sizeof(pre));
	for (int u = 0; u < V; ++u) {
		dis[u][u] = 0;
		Q.push({ u, u });
	}
	while (!Q.empty()) {
		auto [u, v] = Q.front();
        Q.pop();
		for (int dir = 0; dir < 4; ++dir) {
			for (auto nu : { u, E[u][dir ^ 2] }) {
				if (E[nu][dir] != u) continue;
                for (auto nv : {v, E[v][dir ^ 2]}) {
                    if (E[nv][dir] != v) continue;
                    if (dis[nu][nv] != -1) continue;
                    dis[nu][nv] = dis[u][v] + 1;
                    pre[nu][nv] = dir;
                    Q.push({ nu, nv });
                }
			}
		}
	}

	vector<int> us(V);
	for (int u = 0; u < V; ++u) {
		us[u] = u;
	}

	string ans;
	for (; us.size() > 1; ) {
		int mn = -1;
		int tu = -1, tv = -1;
		for (int i = 0; i < us.size(); ++i) {
			for (int j = i + 1; j < us.size(); ++j) {
				if (mn = max(mn, dis[us[i]][us[j]])) {
					tu = us[i];
					tv = us[j];
				}
			}
		}
        // cerr << tu << " " << tv << endl;
        // cerr << dis[tu][tv] << endl;
		for (int u = tu, v = tv; u != v; ) {
			const int dir = pre[u][v];
			ans += dirs[dir];
			u = E[u][dir];
			v = E[v][dir];
			for (int& w : us) {
				w = E[w][dir];
			}
		}
        //cerr << ans << endl;
		sort(us.begin(), us.end());
		us.erase(unique(us.begin(), us.end()), us.end());
	}

	cout << ans << endl;
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4
1111
1001
1001
1110

output:

RRUULLLUUU

result:

ok AC

Test #2:

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

input:

2 15
111111111111111
101010101010101

output:

URRRRRRRRRRRRRR

result:

ok AC

Test #3:

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

input:

1 2
11

output:

L

result:

ok AC

Test #4:

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

input:

20 20
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000010000
00000000000000010100
00000000000000111110
11001100000001101001
01110100111001000111
10011111101111001101
11110100110101001001
01000000001101011101
00000000000011010000
01000000000110010000
11100000001010110000
...

output:

RRRRRLLLLLULLULULULLRRDDDLLLRRDRDDLLLUUDLLRDLRRDRRRULLULLLDLULURDULLDRDRDLDRDRRDLLLULLDLDRRDDLLLDLDRRRRLUULURDULLRRUUUURUUURDRRRRRULLLULLDLLLUUL

result:

ok AC

Test #5:

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

input:

20 20
10101010000000111100
11111110000000100111
00101000000000000101
11101100000000001011
01000101100000001101
01001110111010111011
00111011001011101010
00101001111001001111
11001011000111011010
01010110000000110100
11110010000101011100
10011111101101110011
10101000100111000110
11100111111100111011
...

output:

ULLRURRRRUURUULLULULLLUULLLLLULLLUUDLLRDDDRRURUULULULLLUULLLLLULLLUURURRRRRRDRDRDLLLULULULLLUULLLLLULLLRRRDRRRRRDLDRRRDDRDDRDLLLLLULULULLLUULLLLLULLLRRRDDRRRRRDLLDRRRDLUULRRURRUUURUUULLRRDDDLDDDLLDLLDLLLUULLUULDRDLLDRRDLDRRRDDLLDLUULRRURRUUURUUULLRRDRDDLDDDRRDLLDRRRDLUULDLLLUULLURRUURRDDRDDRDRUU

result:

ok AC

Test #6:

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

input:

20 20
11101111101011101010
10110000101100111111
11011111100101001010
10010010110111110111
01101001101101010101
11001111010101011001
01110101110010001111
11010100001110011001
01010111101011100111
10111100100100111101
11001011111101010100
10111010010011010011
10100110111110111110
11101011010101101000
...

output:

LURURURRRRRRLDRRRRLLLLDRRRRLULULLDDLLLURUURRRULLURRDDDRRRRLLDRULULDLLULLDDLLLLRURRRUULLUUURUULULURRULURRUURULLLRRDDDDRRRUUUUUUULLURRULURULLLRRRDDRDDRDRDDDDLDRRDRRUUUUDDDDLLULLUUUUULLUULURRRULLLRRRDLLDRRLDLDRRDDLDDDRRDDDDLLULLUUUUULLURRULURULLLDDRRDLLDDRRURRRRDDRDRDRRDDLLDRLDLDRRDDLDDRRUUUULUURUUURDR...

result:

ok AC

Test #7:

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

input:

10 10
1010100000
1111110000
0001010000
0101000000
1111100000
1001000000
1110000000
1011000000
0001100000
0000110000

output:

LRDLRDLRDLULULULLUURUDRRULLUURUDRRR

result:

ok AC

Test #8:

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

input:

12 12
000000011101
000011110111
000001010001
000011000011
000010000000
000010000000
000000000000
000000000000
000000000000
000000000000
000000000000
000000000000

output:

DDUULLURUURRULLRRDLL

result:

ok AC

Test #9:

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

input:

20 20
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000100000000000
00000011110000000000
00000001010000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
00000000000000000000
...

output:

URRRLU

result:

ok AC

Test #10:

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

input:

20 20
00000000000111111111
00000000000010010100
10000000000001110111
10000000110010010100
11000011010011010001
01000010010101011111
01110111110111110000
11011101011100100011
01000000110000111110
11000000000000101010
01110100100001101101
11011111111000010111
10000010101001111010
11000011000111010010
...

output:

ULLUURRRRRLLLLUULLLDLLLLLLRRURRDDDDRRURUUURUDLLULUULLUULLLDLLULLLLUDLLUULUULDDDLLULLLLDLLURULUULRRDRRURRRRDRRURRUUDDLLDRDLLDRRDRRUULLLLRULLDRDDDDDLLLLDLLURRDLRRURDRRRDDDDD

result:

ok AC

Test #11:

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

input:

2 1
1
1

output:

U

result:

ok AC

Test #12:

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

input:

20 20
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
...

output:

RRRULLLULLRRDLLRRURRDLLRRURRDLLRRURRDLLULLLDLLULLDLLULLDLLULLDLLLLUUUDDRUURRRRRRRRRRRRRRRRRRRUUDDDLUUULLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDDLUUULLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDDLUUULLLLLLLLLLLLLLLLLLLUU

result:

ok AC

Test #13:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRLLULULULULULULULULULULULULULULULULDLDDDRDRDRDRDRDRDDLLULULULLRDRDRDRDRDRDRDRDRDDLLULULULULULULULULULLRDRDRDRDRDRDRDRDRDRDRDRRDDLULLULULULULULULULULULULULULULULULDLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRRUUDRURDRURLDLULULULULULULULULULULULULULULULLUU

result:

ok AC

Test #14:

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

input:

20 20
11101110111110111110
10011011001011001011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
...

output:

ULLULULULULULULULULULULULULULULULULULDDDDRDRUUDDRUULULUURDRDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULULLRRDRDRDRDRDRDRDRDRDRDRDRRRDDLULULULULULULULULULULULULULULULULULLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUULULULULULULULULULULULULULULULUU

result:

ok AC

Test #15:

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

input:

20 20
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
...

output:

URRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLDDLLLLLLLLLLLLLLLLLLLUUDDRDRULUURRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDRDRULUURRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDRDRULUURRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDRDRULUURRRRRRRRRRRRRRRRRRRUU

result:

ok AC

Test #16:

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

input:

20 20
00111100111100111101
11101011101011100001
10100110100110100111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
...

output:

RRRRURDLLURURURURULLRURURURURURURRDDLDLDLDLDLDLDLDLUUDLURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLLDURRURURURURURURURURURURURURURURURULLRDRUUDDLLDLDDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLUURURURURURURURURURURURURURURDDUULLDLDDLDLDLDLDLDLDLDLDLDLDLUURURURURURURURURDD

result:

ok AC

Test #17:

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

input:

20 20
01000111000111000111
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
01011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
01011011011011011010
11101101101101101100
...

output:

RRLLULULULULULULULULULULULULLDDRDRDRDRDRDRDRDRDRUUDDLLULULULULULULLDDRDRDRUULULULULULURULLDDRDRDRDRDRDRDRDRDRUULULULULULULULULULULULULULURULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRUUDRDLLULULULULULULULULULULULULULULULULLURULDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLL

result:

ok AC

Test #18:

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

input:

20 20
10111110111110111101
11101001101001101001
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
...

output:

LRURURURULLDLDLDRRURURURURURURURURURURRDDLDLDLDLDLDLDLUUDLURURURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLDLDLDLUUDLURURURURURURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDLDLDLLUURURURURURURURURURURURURURURURURUU

result:

ok AC

Test #19:

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

input:

20 20
10111110111110111110
10001011001011001011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
...

output:

ULULULULULULULULULULULULULULULULULUULDDDDRDRUUDRULULUURDRDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULULLULULULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDDLULULULULULULULULULULULULULULULULULLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUU

result:

ok AC

Test #20:

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

input:

20 20
10011111011111011111
11100101100101100101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
...

output:

UULLULULULULULULULULULULULULULULULULUULDLLLLDDDRDRUUUDDRUULULUURDRDRDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULULULLULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRRRDDLULULULULULULULULULULULULULULULULULULRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUULULULULULULULULULULULULULULUU

result:

ok AC

Test #21:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRLLULULULULULULULULULULULULULULULULDLDRRDRDRDRRRLULLULULULULULULULULULULULULULULULLDDRDRDRDRDRDRDRDRDRDRDRDRUULULULULULULULULULULULULDDUURDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRRUUUDLDLULULULULULULULULULULULULULULULLUU

result:

ok AC

Test #22:

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

input:

20 20
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
...

output:

RRURRRDLLRRURRRDLLRRURRRDLLRRURRRDLLULLLDLLULLDLLULLDLLULLDLLDDDLUUURRRRRRRRRRRRRRRRRRRUUDDLDLURUULLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLDLURUULLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLDLURUULLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLDLURUULLLLLLLLLLLLLLLLLLLUU

result:

ok AC

Test #23:

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

input:

20 20
00011100011100011100
00010110010110010110
00011011011011011011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
00011011011011011000
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
...

output:

RRUULULULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRUULULULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRUULULULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRUULULULULULDDRDRDRDRDDLULULULULULULULULULULDDRDRDRDRDRDRDRDRDRDRDDLULULULULULULULULULULULULULULULUU

result:

ok AC

Test #24:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRLLULULULULULULULULULULULULULULULLDDDDRDRDRDRDRDRDDLLULULULLRDRDRDRDRDRDRDRDRDDLLULULULULULULULULULLRDRDRDRDRDRDRDRDRDRDRDRRRDDLLULULULULULULULULULULULULULULULLULULLDDRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUUDRDRDLULULLULULULULULULULULULULULULULULLUU

result:

ok AC

Test #25:

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

input:

20 20
01101111011111011111
11011010010010010010
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
00110110110110110111
11101101101101101101
10011011011011011011
...

output:

LRURULLLDLLLRURRRURURURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLDLUUDDRRURURURURURURURULLDLDLDLDLDLDLDLDLLUURURURURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLLLUUDLLLURRRURURURURURURURURURURURURURURURUULDLLDDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDURUURRURURURURURURURURURURURU

result:

ok AC

Test #26:

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

input:

20 20
10101010101010101010
10111111111111111111
11000000000000000001
10111111111111111111
10100000000000000000
10111111111111111111
11000000000000000001
10111111111111111111
10100000000000000000
10111111111111111111
11000000000000000001
10111111111111111111
10100000000000000000
10111111111111111111
...

output:

RRRRRRRRRRRRRRRRRRRDLLLLLLLLLLLLLLLLLLLDLLLLLLLLLLLLLLLLLLLDDRRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDDDRRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDDDRRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDDDRRRRRRRRRRRRRRRRRRRUUDDLLLLLLLLLLLLLLLLLLLDDDRRRRRRRRRRRRRRRRRRRUU

result:

ok AC

Test #27:

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

input:

20 20
11011111011111011111
10110100110100110101
11101101101101101101
10011011011011011010
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
...

output:

RRURURULLRURULDLDLDLLURURURURURURURURULLRRDDLDLDLDLDLDLUUDLURURURURURURUURLLDLDLDLDLDLDLDLDLDLLDURURURURURURURURURURURURURURULLRUDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDDLLUUDLDLDLRURURURURURURURURURURURURURURURURUULLDLDLDLDLDLDLDLDLDLDLDLDLDLDLL

result:

ok AC

Test #28:

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

input:

20 20
01101111101111101110
11011010011010011010
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
...

output:

LRURULLDRRURURULDLDLLURURURURURURURULLRRDDLDLDLDLDLUUDLURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLDLUUDLURURURURURURURURURURURUURURURURURRDDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLUUDDDURURURURURURURURURURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLL

result:

ok AC

Test #29:

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

input:

20 20
01111101111101110111
11010011010011010101
10110110110110110101
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
...

output:

RRRRULLURURURURUULLDLDLDLUDLUDLLURURURURURURURURURURURURURURURUUURRDDLDDLDLDLDLDLDLDLDLDLDLDLDLDLDLUUDDRRURURURURURURURURURURULLDLDLDLDLDLDLDLDLDLDLDDRRRLULURURURURURURURURURURURURURURURUUUULLDDURRDDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDDLLDUURURURURURURURURURURURURURURURURUU

result:

ok AC

Test #30:

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

input:

20 20
11011111011111011111
10110100110100110100
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
...

output:

RRURURULLRURULDLDLDLLURURURURURURURURULLRRDDLDLDLDLDLDLUUDLURURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLDLDLUUDLURURURURURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLUUDLUDLURDRURURURURURURURURURURURURURURURURU

result:

ok AC

Test #31:

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

input:

20 20
11110001110001110001
01011001011011011001
01101101101101101111
00110110110110110100
00011011011011011000
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
00011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
...

output:

RRUULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRUULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRUULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRRULULULULULULULULULULULULULULULULULLUURURRDRDLLLULULLDLURRDRDRDRDRDRDRDRDRDLLRDRDRDRDRDRDRRUULULULULULULULULULULULULUU

result:

ok AC

Test #32:

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

input:

20 20
11111110011110111110
00001011101011001011
11101100101101101100
10110110110110110111
11011011011011011010
01101101101101101111
10110110110110110101
10011011011011011011
11101101101101101100
10110110110110110111
11011011011011011010
01101101101101101111
10110110110110110010
10011011011011011011
...

output:

RRRRRRRLLULLLLLULULULULULULULULULULULDLLLLLLRRULLLULULULULULULULULULULULLDDRDRDRDRDRDRDRDRUULULULULULULULULDDUUUUDDRDRDRDRDRDRDRDRDRDRDRDRDRDRUULLULULULULULULULULULULULULULLLUURDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDDLLRDRDRUULULULULULULULULULULULULUULLULLUU

result:

ok AC

Test #33:

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

input:

20 20
11011111011111011111
10110100110100110100
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
...

output:

LRURURULLDLDRRURURURULDLDLDLLURURURURURURURURULLRRDDLDLDLDLDLDLUUDLURURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLDLDLUUDLURURURURURURURURURURURURUURLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDDLDLDDLRUURURURURURURURURURURURURURURURURURU

result:

ok AC

Test #34:

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

input:

20 20
10111110111110111110
10001011001011001011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
...

output:

ULLULULULULULULULULULULULULULULULULULDDDDRDRUUDRULULUURDRDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULULLULULULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDDLULULULULULULULULULULULULULULULULULLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUU

result:

ok AC

Test #35:

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

input:

20 20
11011100011100011101
10110110110110110111
11101101101101101101
01011011011011011010
00110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101100
10011011011011011010
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
...

output:

LRURURULLRURURURURURURURRDDLDLDLDLDLDLUURURURURURURRUURURURURURULURRDDLDLDLDLDLDLDLDLDLDLDLDLUURURURURURURURURURURURURRUURULURRDDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLUURURURURURURURURURURURURURURURURUURDLLULLDLDLDRRURURRDLDLDLDLDLDLDLDLDLDLDLDLDLDLLUURURURURURURURURURURURUU

result:

ok AC

Test #36:

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

input:

20 20
11111111111111111111
10101010010101010101
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
10000000000000000000
11111111111111111111
00000000000000000001
11111111111111111111
...

output:

RRRRRRRRRRRRRRRRRRRLLLLLLLLLLLLLLLLLLLDDLLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLLLLUUDDRRRRRRRRRRRRRRRRRRRDDLLLLLLLLLLLLLLLLLLLUURRRRRRRRRRRRRRRRRRR...

result:

ok AC

Test #37:

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

input:

20 20
10011111011111011111
11100101100101100101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
...

output:

UULLULULULULULULULULULULULULULULULULUULDDDDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULLRDRDRDRDRDRDRDRDRDRDRDRDDLLULULULULULULULULULULULULLULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRRRDDLULULULULULULULULULULULULULULULULULULRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDDLL

result:

ok AC

Test #38:

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

input:

20 20
11000111110111110111
01001101001101001101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
...

output:

RRRRLLLLRRURURURURURURULLDLDLDLLLDDRURURURURURURURURURURURURURURRDDLDLDLDLDLDLDLDLDLDLUURURURURURURURURURURDDUUUDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLUUDLDRURURURURURURURURURURURURURURURURUULLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLL

result:

ok AC

Test #39:

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

input:

20 20
10111110111110111011
11101001101001101010
10011011011011011010
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101100
10011011011011011010
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101100
...

output:

LURURURURULLRURURURURURURRDDLDLDLDLDLDLDLUURURURURURURURRUURURURURURULURRDDLDLDLDLDLDLDLDLDLDLDLDLDLUURURURURURURURURURURURURURRUULUUUDRDDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDUURURURURURURURURURURURURURURURURUU

result:

ok AC

Test #40:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRLLULULULULULULULULULULULULULULULULDLDDDRDRDRDRDRDRDDLLULULULLRDRDRDRDRDRDRDRDRDDLLULULULULULULULULULLRDRDRDRDRDRDRDRDRDRDRDRDRRDDLLULULULULULULULULULULULULULULULLULULLDDRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUUDRUDRULDLULULULULULULULULULULULULULULULLUU

result:

ok AC

Test #41:

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

input:

20 20
11111101111101110111
10010011010011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011001
10110110110110110111
11101101101101101100
10011011011011011010
...

output:

RRRRURDLLURURURURULLRURURURURURURRDDDLLDLDLDLDLDLDLUUDLUDLUDLUDDLDDRURURURURURURURURURURURULLRURURURURURRDDLDLDLDLDLDLDLDLDLDLDLDLDLDLUUDLUDDLRURURURURURURURURURURURURURURURURULLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDUURURURURURURURURURURURURURURURUUDDLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLL

result:

ok AC

Test #42:

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

input:

20 20
00111110111110111110
01101001101001100011
11011011011011011110
10110110110110110001
01101101101101101111
11011011011011011001
10110110110110110111
11101101101101101100
10011011011011011001
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101101
...

output:

LRURURURULLDLDLDRRURURURURURURURURURURRDDLDLDLDLDLDLDLUUDLURURURURURURURURURURURURURRRDLDLLDLDLDLDLDLDLDLDLDLDLDLUURURURURURURURURURURURURRUURLLLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLLDDDURUURRURURURURURURURURURURURURURURRRUULLDLLDLDLDLDLDLDLDLDLDLDLDLDLDLLUURURURURURURURURURURUU

result:

ok AC

Test #43:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRLLULULULULULULULULULULULULULULULULDLDDDRUURDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULLRDRDRDRDRDRDRDRDRDRDRDRDRRDDLLULULULULULULULULULULULULULULULLULULLDDRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUUDRUDRULDLULULULULULULULULULULULULULULULLUU

result:

ok AC

Test #44:

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

input:

20 20
00001110001110001110
00001011001011001011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
00011011011011011000
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
00011011011011011000
...

output:

RRUULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDLLULULULULULURDRDRDRDRDRRULULULULULULULULULULULLURRDRDRDRDRDRDRDRDRDRDRDRRULULULULULULULULULULULULULULULULLURRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUULULULULDDRDRDRDDLULULULULULULULULULDDRDRDRDRDRDRDRDRDRDDLULULULULULULULULULULULULULULUU

result:

ok AC

Test #45:

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

input:

20 20
11111101111101111101
10010110010110010111
01011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
...

output:

RRLLULULULULULULULULULULULULULULULULLDDDDRUUDRULUURDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULLULULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRUUDRDRDRDDLLULULULULULULULULULULULULULULULULLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUULULULULULULULULULULULULULULULULUULLL

result:

ok AC

Test #46:

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

input:

20 20
11100011100011101100
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011010
11101101101101101100
10110110110110110110
...

output:

URUULLULULULULULULULULULULULULULULULULLUDDRRDRRULLLULLULULULULULULDLUUDDRRDRDRDRDRDRDRRUULULULULULULULULULDDDUUUDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRUUDLLULULULULULULULULULULULULULULULULLUURURRDRDRDRDLLULULULULLDLURRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLDRRUULULULULULULULULULULULULULUU

result:

ok AC

Test #47:

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

input:

20 20
11111000111000111011
00101101101101101110
10110110110110110011
10011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRURDLLLULULULULULULULULULULULULULULULDLDDDRDRDRDRDRDRDDLLULULULLRDRDRDRDRDRDRDRDRURDDLLULULULULULULULULULDLRRDRDRDRDRDRDRDRDRDRDRURDDLLLULULULULULULULULULULULULULULULDLRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRRDDRUURUDLLDLULULULULULULULULULULULULULULULLUU

result:

ok AC

Test #48:

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

input:

20 20
11101110111011101111
10111011101110111001
10010101010101010101
11101110111011101110
10111011101110111011
01010101010101010010
11101110111011101110
10111011101110111011
10010101010101010101
11101110111011101110
10111011101110111011
01010101010101010010
11101110111011101110
10111011101110111011
...

output:

LRULULLRULDRDLLRRURULDRDLLRRURULDRDLLRRURULDRDLLDLLDLLDLLRRURRUDRRUUULLRRDRRURRDRRURRDRRULULLRRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUUDDDRRDRRURRDRRURRDRRURRDRRURRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUUDDDRRDRRURRDRRURRDRRURRDRRURRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUU

result:

ok AC

Test #49:

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

input:

20 20
11101110111011101110
10111011101110111011
10010101010101010101
11101110111011101110
10111011101110111011
01010101010101010010
11101110111011101110
10111011101110111011
10010101010101010101
11101110111011101110
10111011101110111011
01010101010101010010
11101110111011101110
10111011101110111011
...

output:

LRULULLRULDRDLLRRURULDRDLLRRURULDRDLLRRURULDRDLLDLLDLLDLLRRURRUDRRUUULLRRDRRURRDRRURRDRRULULLRRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUUDDDRRDRRURRDRRURRDRRURRDRRURRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUUDDDRRDRRURRDRRURRDRRURRDRRURRDDDDRDLUUULULLDLLULLDLLULLDLLULLDLLULLUUU

result:

ok AC

Test #50:

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

input:

20 20
11101111011011101111
10110101110010110010
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011010
11101101101101101101
10110110110110110111
11011011011011011001
01101101101101101101
10110110110110110111
11011011011011011001
01101101101101101101
10110110110110110110
...

output:

RRRRRRRLULLLLLLUUULULULULULULULULULULULLDRRRRRLULLLLLLUUULULULULULULULULULULULLDDDRRRRRRRRRUULULULULULULULULULULULULDRDRDRDDRDRDRDRRUUDRDRDRUUULULULULULULULULULDDDDLLULULULULULULULULULLDDRDRDRDRDRDRDRDRDRDRDRDRDDDRRRRLULULULULULULULULULULULULULULULULULLUUDRRRDRRDRDRDRDRDRDRDRDRDLLULULULULULULULULULL...

result:

ok AC

Test #51:

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

input:

20 20
01000111011111011111
11101101100101100101
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
01011011011011011010
11101101101101101100
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
01011011011011011010
11101101101101101100
...

output:

RRLLULULULULULULULULULULULULLDDRDRDRDRDRDRDRDRDRUUDDLLULULULULULULLDDRDRDRUULULULULULURULLDDRDRDRDRDRDRDRDRDRUULULULULULULULULULULULULULURULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRUUDRDLLULULULULULULULULULULULULULULULULLURULDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDLL

result:

ok AC

Test #52:

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

input:

20 20
11111011111011111011
00101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
00110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
...

output:

RRRLUULULULULULULULULULULULULUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDLLRDLLULULULULULULULULULULULULULULULLDRDRDRDRDRDRDRDRDRDRDRDRUUDRUDDLULULULULULULULULULULLUDRDRDRDRDRDRDRDRDRDRDRDRRDDLULULULULULULULULULULULULULULULULDLUUDDRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRULULULULULULULULULULULULULULULULULUULL

result:

ok AC

Test #53:

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

input:

20 20
10111011111011111001
10101100101100101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
10011011011011011011
11101101101101101101
...

output:

RRRLLULULULULULULULULULULULULULULULULDLRDDDDRRDRDRDRDRUUDRDRDRDRDRDRDRDDLLULULULULULULULULULULRDRDRDRDRDRDRDRDRDRDRRUULULULULULULULULULULULULULULRRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUUDRULDLULULULULULULULULULULULULULULULLUURRDRDRDRDRDRDRDRDRDRDRDRDRDRDLL

result:

ok AC

Test #54:

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

input:

20 20
01111101111101111100
10010110010110010110
10011011011011011011
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
10011011011011011001
11101101101101101101
10110110110110110110
11011011011011011011
01101101101101101101
10110110110110110111
...

output:

RRLLULULULULULULULULULULULULULULULULLDDDDRUUDRULUURDRDRDRDRDRDRUUDRDRDRDRDRDRDDLLULULULULULULULULULULLULULULULULLDDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDDLLULULULULULULULULULULULULULULULULLLRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRDRRUUDRU

result:

ok AC

Test #55:

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

input:

20 20
01110001110001110000
11010011010011010000
10110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101100
00011011011011011000
00110110110110110111
01101101101101101101
11011011011011011011
10110110110110110110
11101101101101101100
00011011011011011000
...

output:

RRURDLLURURURURULLRULDLDLDLDLDLLURURURURURURURURURURULLDLDLDLDLDLDLDLDLDLDLDLLDUURURURURURURURURURURURURURURURULLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDLDDLLDUUUDDRUURURURURURURURURURURURURURURURUUDDLDLDLDLDLDLDLDLDLDDRRURURURURURURURURURURURULLRRDDLDLDLDLDLDLDLDLDLDDRRURURURURURURURURURURURULL

result:

ok AC

Extra Test:

score: 0
Extra Test Passed