QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#710955 | #8981. Kangaroo Puzzle | xhytom | RE | 1ms | 3792kb | C++23 | 3.1kb | 2024-11-04 23:27:22 | 2024-11-04 23:27:24 |
Judging History
answer
/*
_/ _/ _/ _/ _/ _/ _/_/_/_/_/ _/_/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/_/
_/_/ _/_/_/_/_/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/ _/ _/ _/
_/ _/ _/ _/ _/ _/ _/_/ _/ _/
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
using i64 = long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define multi int _;cin>>_;while(_--)
#define int long long
#define pb push_back
#define eb emplace_back
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a;}
mt19937_64 mrand(chrono::steady_clock().now().time_since_epoch().count());
int rnd(int l,int r){ return mrand() % (r - l + 1) + l;}
#ifdef localfreopen
#define debug(x) cerr << #x << " = " << (x) << endl;
void test() {cerr << "\n";}
template<typename T, typename... Args>
void test(T x, Args... args) {cerr << x << " ";test(args...);}
#else
#define debug //
#define test //
#endif
const ll MOD = 998244353;
// const ll MOD = 1e9+7;
ll ksm(ll x,ll y){ll ans=1;x%=MOD;while(y){if(y&1)ans=ans*x%MOD;x=x*x%MOD,y/=2;}return ans;}
const int P1 = 972152273, base1 = 809;
const int P2 = 905563261, base2 = 919;
const ll N = 200005;
//head
signed main()
{
#ifdef localfreopen
// freopen("1.in","r",stdin);
#endif
fastio
std::cout << std::fixed << std::setprecision(10);
int n, m;
std::cin >> n >> m;
std::vector is(n + 1, std::vector<int> (m + 2));
for (int i = 1; i <= n; i++) {
std::string s;
std::cin >> s;
for (int j = 0; j < m; j++) {
is[i][j + 1] = s[j] - '0';
}
}
std::string ans;
std::vector<std::pair<int, int>> D = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
std::vector<char> target = {'R', 'L', 'D', 'U'};
auto dfs = [&](auto self, int x, int y, int fx, int fy, int rx, int ry, std::string s)->void{
int cnt = 0;
for (int k = 0; k < 4; k++) {
auto [dx, dy] = D[k];
int nx = x + dx, ny = y + dy;
if (nx < 1 || nx > n || ny < 1 || ny > m || is[nx][ny] == 0 || (nx == fx && ny == fy)) continue;
cnt++;
self(self, nx, ny, x, y, rx, ry, s + target[k]);
}
if (cnt == 0) {
ans += s;
}
};
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (is[i][j] == 1) {
dfs(dfs, i, j, 0, 0, i, j, "");
}
}
}
while (ans.size() < 50000) ans += "LRDU"[rnd(0, 3)];
assert(ans.size() <= 50000);
std::cout << ans << "\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3732kb
input:
4 4 1111 1001 1001 1110
output:
RRRDDDDDRRRRDDLDDDRRRDDLLDDDRRLLLDDDRRDDDDRRURRRDDDULLLDDDRRDRRUURRRDDUULLLDDDRRRRUUURRRDDRLUUURRRDDLLUUURRRDDULRUUDRRDLDRLUDLLLRUULDRRRDUUDRUUUULRDLLRLRLUUUDRLLDLDUDLLUULLUULRLDRLRUDDDDURRDLRRRRRDDUUUURLRRLDUUUDRLDDURRULRDRDUDRUDUURUDLRUUDRURLRDLDRDDDRDLRLDULRRLRUULURRDDRDLLDURDLDURULDLLLUDUDLURRDL...
result:
ok AC
Test #2:
score: 0
Accepted
time: 1ms
memory: 3664kb
input:
2 15 111111111111111 101010101010101
output:
RRRRRRRRRRRRRRDRRRRRRRRRRRRDRRRRRRRRRRDRRRRRRRRDRRRRRRDRRRRDRRDDRRRRRRRRRRRRRDRRRRRRRRRRRDRRRRRRRRRDRRRRRRRDRRRRRDRRRDRDLDRRRRRRRRRRRRDRRRRRRRRRRDRRRRRRRRDRRRRRRDRRRRDRRDLLDDRRRRRRRRRRRDRRRRRRRRRDRRRRRRRDRRRRRDRRRDRDLLLDLDRRRRRRRRRRDRRRRRRRRDRRRRRRDRRRRDRRDLLLLDLLDDRRRRRRRRRDRRRRRRRDRRRRRDRRRDRDLLLL...
result:
ok AC
Test #3:
score: 0
Accepted
time: 1ms
memory: 3792kb
input:
1 2 11
output:
RLURUDRRURRRRUDLLRLLUDDURDDRUDDDULLDDRRUDRLRDRRULRLUURULUUDRDRRDRURRURLRLUULRRDDUDDDUDLLRUDUUDUDDLRLLRURDLULRRLLRLRLRUDRUULRDDRLDLUUUDDRRRUDLUUUUDRLURDRLDLURDLRLLDRURURLRLLRUUDRLLUDRULUURRUDURLDDUDLDDURRURLUDUDRLDDRLRUDLLLUDRLURRDDRLRRULDRUDDULLLURDLLURUDDULRUUURRDDULURLRRLLRLUULLRDRDURRURRRLRLRDDRR...
result:
ok AC
Test #4:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
2 1 0 1
output:
URDLRDDDRRLLULDUULRULDDDULLLRULLRDDDULLLRRRUURURRDLUULLULURUUUDRULULDLUURLDURRDRRLDDUURUDURLLDDRLURLRLLDUDUDUURRLUUDUUULUDUULDLLLULRRRUDLUDLUDDLDURURDLRUDUUDURURLUURULRRRDDUDLDDRLULLUDRRDULURURDLDRRLDRLRUDRDRRDLRLRLRLDDDRRDDRDDRLRDDLLDLRDLUULLUDULDDLRDURDDRUDLRRRDRDUURLLDDLRURDRDULUUDRDDUDLRULLLRRUL...
result:
ok AC
Test #5:
score: -100
Runtime Error
input:
20 20 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000010000 00000000000000010100 00000000000000111110 11001100000001101001 01110100111001000111 10011111101111001101 11110100110101001001 01000000001101011101 00000000000011010000 01000000000110010000 11100000001010110000 ...