编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#2452 #1005. 兜圈子 Accepted 100 366 ms 860 K C++ 17 (Clang) / 1.3 K JimmyHu 2023-11-17 22:17:45
显示原始代码
#include <bits/stdc++.h>
using namespace std;
int main() {
    int h, w, totx = 1, toty = 1, test = 1;
    cin >> h >> w;
    char map[h + 5][w + 5];
    bool check[h + 5][w + 5];
    memset(check, false, sizeof check);
    memset(map, 'x', sizeof map);
    for (int i = 1; i <= h; i++)
        for (int j = 1; j <= w; j++) cin >> map[i][j];
    while (test) {
        if (check[totx][toty])
            test = 0;
        if (map[totx][toty] == 'U' && map[totx - 1][toty] != 'x') {
            check[totx][toty] = true;
            totx -= 1;
        } else if (map[totx][toty] == 'U' && map[totx - 1][toty] == 'x') {
            cout << totx << ' ' << toty << endl;
            return 0;
        }
        if (map[totx][toty] == 'D' && map[totx + 1][toty] != 'x') {
            check[totx][toty] = true;
            totx += 1;
        } else if (map[totx][toty] == 'D' && map[totx + 1][toty] == 'x') {
            cout << totx << ' ' << toty << endl;
            return 0;
        }
        if (map[totx][toty] == 'L' && map[totx][toty - 1] != 'x') {
            check[totx][toty] = true;
            toty -= 1;
        } else if (map[totx][toty] == 'L' && map[totx][toty - 1] == 'x') {
            cout << totx << ' ' << toty << endl;
            return 0;
        }
        if (map[totx][toty] == 'R' && map[totx][toty + 1] != 'x') {
            check[totx][toty] = true;
            toty += 1;
        } else if (map[totx][toty] == 'R' && map[totx][toty + 1] == 'x') {
            cout << totx << ' ' << toty << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:5 ms
内存:228 KiB

输入文件(00_sample_00.in

2 3
RDU
LRU

答案文件(00_sample_00.out

1 3

用户输出

1 3

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:5 ms
内存:352 KiB

输入文件(00_sample_01.in

2 3
RRD
ULL

答案文件(00_sample_01.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:5 ms
内存:312 KiB

输入文件(00_sample_02.in

9 44
RRDDDDRRRDDDRRRRRRDDDRDDDDRDDRDDDDDDRRDRRRRR
RRRDLRDRDLLLLRDRRLLLDDRDLLLRDDDLLLDRRLLLLLDD
DRDLR
<310 bytes omitted>

答案文件(00_sample_02.out

9 5

用户输出

9 5

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:25 ms
内存:784 KiB

输入文件(01_random_1_00.in

500 500
RRUURUUURDRURLLLUDDRLRUUUURRRLRUUULRLURDUDUURDRRUDDRDLLLRRLLLLULRUULRRLDDRURDLULDUDDLRRRLUDR
<250408 bytes omitted>

答案文件(01_random_1_00.out

1 3

用户输出

1 3

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:31 ms
内存:796 KiB

输入文件(01_random_1_01.in

500 500
DDDUUULULDUUUUDRULURDLLULUURDLRUULDLUDRLLDDDULUURDLLDLDDRDULUUURULDRDUDUDDRDLLLLRDDUULLRLUUD
<250408 bytes omitted>

答案文件(01_random_1_01.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:31 ms
内存:760 KiB

输入文件(01_random_1_02.in

500 500
LULRRLLRDDULRUULRDULRUDUDLDDULRUDLLRRDULDRLDUDLDRULUUDUURLLLDRRLLDUUULUURRLRLLLDDRLDLDDRUDRD
<250408 bytes omitted>

答案文件(01_random_1_02.out

1 1

用户输出

1 1

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:34 ms
内存:860 KiB

输入文件(02_random_2_00.in

500 500
RRRDLURDUUDLRRRUURUDLUDRURURUURUDDRUDDDDURUDURULDLRRRLDRDDRDDULURDDDLRDURUDDRLUUDRLUDLLDURRL
<250408 bytes omitted>

答案文件(02_random_2_00.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:32 ms
内存:840 KiB

输入文件(02_random_2_01.in

500 500
RRRRRDDLDLDLRRRRDLRLLLLLRUUURRUDRURDULLDLUUDLULLDLURUDDLRLRRLLRLRUUURLURDURULLRRRDULRDLDDLUU
<250408 bytes omitted>

答案文件(02_random_2_01.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:32 ms
内存:844 KiB

输入文件(02_random_2_02.in

500 500
DRDULLRDDURDLLLUDULRLLRRDLDUDDUULDDURUDDURDDRLRDRDRRLURDRUDLRULDRDRDURUUUDDRDDRLRDRLRUURRRUL
<250408 bytes omitted>

答案文件(02_random_2_02.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:37 ms
内存:828 KiB

输入文件(03_max_00.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_00.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:34 ms
内存:824 KiB

输入文件(03_max_01.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_01.out

341 1

用户输出

341 1

系统信息

Exited with return code 0
测试点 #12
Accepted
得分:100
用时:30 ms
内存:836 KiB

输入文件(03_max_02.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_02.out

500 432

用户输出

500 432

系统信息

Exited with return code 0
测试点 #13
Accepted
得分:100
用时:33 ms
内存:796 KiB

输入文件(03_max_03.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_03.out

432 500

用户输出

432 500

系统信息

Exited with return code 0
测试点 #14
Accepted
得分:100
用时:32 ms
内存:796 KiB

输入文件(03_max_04.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_04.out

1 441

用户输出

1 441

系统信息

Exited with return code 0