QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#191754 | #7516. Robot Experiment | ucup-team266# | WA | 1ms | 3632kb | C++14 | 769b | 2023-09-30 10:49:12 | 2023-09-30 10:49:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int vi[45][45],vi2[45][45],an[45][45];
int n;
int dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
char C[4]={'L','R','D','U'};
char c[20];
void dfs(int x,int y,int z){
if(z==n){an[x][y]=1;return;}
int e=-1;
for(int i=0;i<4;i++)if(C[i]==c[z]){e=i;break;}
int ax=x+dx[e],ay=y+dy[e];
if(vi[ax][ay])dfs(x,y,z+1);
else if(vi2[ax][ay])dfs(ax,ay,z+1);
else{
vi[ax][ay]++,dfs(x,y,z+1),vi[ax][ay]--;
vi2[ax][ay]++,dfs(ax,ay,z+1),vi2[ax][ay]--;
}
}
int main(){
scanf("%d%s",&n,c);
vi2[22][22]=1,dfs(22,22,0);
int ans=0;
for(int i=0;i<45;i++)for(int j=0;j<45;j++)if(an[i][j])
ans++;
printf("%d\n",ans);
for(int i=0;i<45;i++)for(int j=0;j<45;j++)if(an[i][j])
printf("%d %d\n",i-22,j-22);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3632kb
input:
2 RU
output:
4 0 0 0 1 1 0 1 1
result:
ok 5 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3608kb
input:
20 LLLRLRLRLLLRLLRLRLLR
output:
1 0 0
result:
wrong answer 1st lines differ - expected: '8', found: '1'