QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#715408 | #8981. Kangaroo Puzzle | Chikon | WA | 0ms | 3632kb | C++23 | 907b | 2024-11-06 11:53:55 | 2024-11-06 11:53:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
int p[25][25]={0};
int gt[25][25]={0};
int X[4]={-1,0,1,0},Y[4]={0,1,0,-1};
char dir[5]="URDL";
void dfs(int x,int y,int from) {
if(p[x][y]==0||gt[x][y]==1) {
return;
}
if(from!=4) {
cout<<dir[from];
}
gt[x][y]=1;
for(int i=0;i<4;i++) {
dfs(x+X[i],y+Y[i],i);
}
if(from!=4) {
cout<<dir[(from+2)%4];
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
int sx,sy;
cin>>n>>m;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
char c;
cin>>c;
p[i][j]=c-'0';
if(p[i][j]) {
sx=i,sy=j;
}
}
}
dfs(sx,sy,4);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3508kb
input:
4 4 1111 1001 1001 1110
output:
LLUUURRRDDUULLLDDDRR
result:
ok AC
Test #2:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 15 111111111111111 101010101010101
output:
ULLDULLDULLDULLDULLDULLDULLDURRRRRRRRRRRRRRD
result:
ok AC
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
1 2 11
output:
LR
result:
ok AC
Test #4:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
20 20 00000000000000000000 00000000000000000000 00000000000000000000 00000000000000010000 00000000000000010100 00000000000000111110 11001100000001101001 01110100111001000111 10011111101111001101 11110100110101001001 01000000001101011101 00000000000011010000 01000000000110010000 11100000001010110000 ...
output:
LLUUURUUUDLRDRRUUUURUUUUURURUUDDRRUDRLLDULLDLDDLLDDLRUULULLDDRLULLLUULRDDDULLULLULRDRRDDLLDULUDRRRURRRRRURRDRRRDDDLDLRDDRLDDRRURUUUUURUURURRUDDDDUUULLDLDDRLLDDDLRDDRRDRRLLULLLDLLULLDLLUDLRRDDDLLLUUDLLULULULUUUDRLLRDDLDDDRRLDULUUURRDRDRDRRDRRRRR
result:
ok AC
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3552kb
input:
20 20 10101010000000111100 11111110000000100111 00101000000000000101 11101100000000001011 01000101100000001101 01001110111010111011 00111011001011101010 00101001111001001111 11001011000111011010 01010110000000110100 11110010000101011100 10011111101101110011 10101000100111000110 11100111111100111011 ...
output:
UUUULRDDDRRURUULULUUUUDLRDRRUUDRRUUURUUUUUDRLDLLDLDDLLRRUULUDRRURRDDRRUURUUUULLULLLDURRRDDURRDDLRDDLDDRLDULLDLDLRDRRUDLLDLLDLLDLLLUULLUUURUULULUULUUUDRRUDLLLLUDDDLDDUULRRUULLUDRRRRDDRDDLDDDUULLDURRURRDRDRRRUULLULRDRRDDLLLDLDLRDDLLDULUUDLLUULRDDLDDDRRUDLLDDRRRDDRRDRLDLLRRUULLLDLLUDDURRURUULLDULUUUUUR...
result:
wrong answer WA