编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#2208 #1005. 兜圈子 Accepted 100 219 ms 12584 K C++ 17 / 1.2 K buerzhu 2023-11-17 0:42:25
显示原始代码
#include <bits/stdc++.h>
using namespace std;
const int N = 510, mod = 998244353;
#define int long long

typedef long long LL;
typedef pair<int, int> PII;

int n, m, k;
char g[N][N];
int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
bool st[N][N];
void dfs(int x, int y) {
    if (st[x][y]) {
        cout << "-1";
        exit(0);
    }
    st[x][y] = true;
    if (g[x][y] == 'U') {
        if (x == 1) {
            cout << x << " " << y;
            exit(0);
        } else
            dfs(x - 1, y);
    }
    if (g[x][y] == 'D') {
        if (x == n) {
            cout << x << " " << y;
            exit(0);
        } else
            dfs(x + 1, y);
    }
    if (g[x][y] == 'R') {
        if (y == m) {
            cout << x << " " << y;
            exit(0);
        } else
            dfs(x, y + 1);
    }
    if (g[x][y] == 'L') {
        if (y == 1) {
            cout << x << " " << y;
            exit(0);
        } else
            dfs(x, y - 1);
    }
    st[x][y] = false;
}
void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) cin >> g[i][j];
    }
    dfs(1, 1);
}
signed main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int t = 1;

    // cin>>t;
    while (t--) solve();
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:8 ms
内存:404 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
内存:288 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
内存:292 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
用时:15 ms
内存:544 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
用时:8 ms
内存:540 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
用时:19 ms
内存:604 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
用时:18 ms
内存:528 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
用时:12 ms
内存:612 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
用时:21 ms
内存:612 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
用时:24 ms
内存:12584 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
用时:21 ms
内存:12556 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
用时:27 ms
内存:12524 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
用时:24 ms
内存:10868 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
用时:12 ms
内存:652 KiB

输入文件(03_max_04.in

500 500
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
<250408 bytes omitted>

答案文件(03_max_04.out

1 441

用户输出

1 441

系统信息

Exited with return code 0