QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#191714#7516. Robot Experimentucup-team266#WA 1ms3840kbC++14770b2023-09-30 10:15:502023-09-30 10:15:51

Judging History

你现在查看的是最新测评结果

  • [2023-09-30 10:15:51]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3840kb
  • [2023-09-30 10:15:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool 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]=1,dfs(x,y,z+1),vi[ax][ay]=0;
		vi2[ax][ay]=1,dfs(ax,ay,z+1),vi2[ax][ay]=0;
	}
}
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: 0ms
memory: 3596kb

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: 3832kb

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: 3840kb

input:

20
LLLRLRLRLLLRLLRLRLLR

output:

1
0 0

result:

wrong answer 1st lines differ - expected: '8', found: '1'