QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#717150 | #8981. Kangaroo Puzzle | KobicGend | WA | 0ms | 3592kb | C++23 | 1.5kb | 2024-11-06 17:03:34 | 2024-11-06 17:03:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const string dir = "DRUL";
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int n, m;
cin >> n >> m;
vector<string> s(n);
for (int i = 0; i < n; i++) {
cin >> s[i];
}
vector<vector<int>> E(n * m);
auto change = [&](int x, int y) {
return x * m + y;
};
auto get = [&](int p) {
return pair(p / m, p % m);
};
int sx = -1, sy = -1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '1') {
sx = i, sy = j;
}
}
}
vector vis(n, vector<int>(m));
string path;
if (sx != -1) {
auto dfs = [&](auto&& self, int x, int y) -> void {
//cerr << "dfs " << x << " " << y << endl;
for (int i = 0; i < 4; i++) {
auto [nx, ny] = pair(x + dx[i], y + dy[i]);
if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
if (s[nx][ny] == '0') continue;
if (vis[nx][ny]) continue;
vis[nx][ny] = 1;
path += dir[i];
self(self, nx, ny);
}
};
vis[sx][sy] = 1;
dfs(dfs, sx, sy);
}
cout << path << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
4 4 1111 1001 1001 1110
output:
LLUUURRRDD
result:
ok AC
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3580kb
input:
2 15 111111111111111 101010101010101
output:
ULLDLLDLLDLLDLLDLLDLLD
result:
wrong answer WA