QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#199647#7516. Robot Experimentucup-team1479#AC ✓0ms3896kbC++142.7kb2023-10-04 13:31:392023-11-04 11:40:57

Judging History

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

  • [2023-11-04 11:40:57]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:0ms
  • 内存:3896kb
  • [2023-10-04 13:31:39]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:3904kb
  • [2023-10-04 13:31:39]
  • 提交

answer

//prepare for coding{{{
//preparaton{{{
#include<bits/stdc++.h>

#define RELEASE
#ifdef RELEASE
#define DB(...) ;
#else
//#define FILE
#ifdef FILE
#define DB(...) fprintf(stderr,__VA_ARGS__)
#else
#define DB printf
#endif
#endif 
//#define MOD_OPERATOR
//#define CMP_OPERATOR
//#define GRP_OPERATOR
//}}}

//constants{{{
const int N=20;
const int FX[4]={-1,+1,0,0},FY[4]={0,0,-1,1};
//}}}

//std{{{
using namespace std;
//}}}

//input and output{{{
inline int Read(){
	char c=getchar();
	int res=0;
	bool b=0;
	while(c>'9'||c<'0')
		b=(c=='-'),c=getchar();
	while(c>='0'&&c<='9')
		res=(res<<3)+(res<<1)+c-'0',c=getchar();
	return b?-res:res;
}

inline int ReadC(){
	char c=getchar();
	while(c!='L'&&c!='R'&&c!='D'&&c!='U')
		c=getchar();
	return c=='L'?0:(c=='R'?1:(c=='D'?2:3));
}
//}}}

//other small functions{{{
//}}}

//variables{{{
int n;
int dr[N+10];
//}}}

//modulo operators{{{
#ifdef MOD_OPERATOR
const int MOD=998244353;

inline int Add(int a,int b){
	return a+b<MOD?a+b:a+b-MOD;
}

inline int MAdd(int &x,int y){
	return (x+=y)<MOD?x:x-=MOD;
}

inline int Mul(int a,int b){
	return 1ll*a*b%MOD;
}

inline int MMul(int &x,int y){
	return x=1ll*x*y%MOD;
}

inline int Pow(int x,int b=MOD-2){
	int res=1;
	while(b){
		if(b&1)
			MMul(res,x);
		MMul(x,x);
		b>>=1;
	}
	return res;
}
#endif
//}}}

//compare operators{{{
inline int Max(int a,int b){
	return a<b?b:a;
}

inline int CMX(int &x,int y){
	return x<y?x=y:x;
}

inline int Min(int a,int b){
	return a>b?b:a;
}

inline int CMN(int &x,int y){
	return x>y?x=y:x;
}
//}}}

//graph operators{{{
#ifdef GRP_OPERATOR
int te=1,head[N+10];
int s,t;

struct EDGE{
	int n,t;
}e[N*2+10];

inline void Adde(int u,int v){
	e[++te].n=head[u];
	e[te].t=v;
	head[u]=te;
	e[++te].n=head[v];
	e[te].t=u;
	head[v]=te;
}
#endif
//}}}
//}}}

//solve{{{
int mp[2*N+10][2*N+10];
bool ok[2*N+10][2*N+10];

inline void DFS(int x,int y,int d){
	if(d==n+1)
		return ok[x][y]=1,void();
	int nx=x+FX[dr[d]],ny=y+FY[dr[d]];
	int tmp=mp[nx][ny];
	if(~tmp){
		mp[nx][ny]=1;
		DFS(nx,ny,d+1);
	}
	if(tmp^1){
		mp[nx][ny]=-1;
		DFS(x,y,d+1);
	}
	mp[nx][ny]=tmp;
}
//}}}

//main{{{
signed main(){
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	n=Read();
	for(int i=1;i<=n;++i)
		dr[i]=ReadC();
	mp[n][n]=1;
	DFS(n,n,1);
	int ans=0;
	for(int i=0;i<=n*2;++i)
		for(int j=0;j<=n*2;++j)
			ans+=ok[i][j];
	printf("%d\n",ans);
	for(int i=0;i<=n*2;++i)
		for(int j=0;j<=n*2;++j)
			if(ok[i][j])
				printf("%d %d\n",i-n,j-n);
	return 0;
}
//}}}
//《象》曰:泽灭木,大过。君子以独立不惧,遁世无闷。

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3796kb

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

input:

4
LRUD

output:

4
0 -1
0 0
1 -1
1 0

result:

ok 5 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

20
LLLRLRLRLLLRLLRLRLLR

output:

8
-6 0
-5 0
-4 0
-3 0
-2 0
-1 0
0 0
1 0

result:

ok 9 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3732kb

input:

1
D

output:

2
0 -1
0 0

result:

ok 3 lines

Test #5:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

20
UUUUUUUUUUUUUUUUUUUU

output:

21
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20

result:

ok 22 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

20
LRUDDULRUDRLLRDURLUD

output:

22
-2 0
-2 1
-1 -2
-1 -1
-1 0
-1 1
-1 2
0 -2
0 -1
0 0
0 1
0 2
1 -2
1 -1
1 0
1 1
1 2
2 -2
2 -1
2 0
2 1
2 2

result:

ok 23 lines

Test #7:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

20
UUDUDUUDUDUDUDUDLLRL

output:

12
-2 -1
-2 0
-2 1
-2 2
-1 -1
-1 0
-1 1
-1 2
0 -1
0 0
0 1
0 2

result:

ok 13 lines

Test #8:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

20
DUUDDUDUUDUDDUUDUDDU

output:

3
0 -1
0 0
0 1

result:

ok 4 lines

Test #9:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

20
RUDLUULDRURLDURLDURR

output:

29
-3 3
-3 4
-2 2
-2 3
-2 4
-1 1
-1 2
-1 3
-1 4
0 -1
0 0
0 1
0 2
0 3
0 4
1 -1
1 0
1 1
1 2
1 3
2 -1
2 0
2 1
2 2
2 3
3 -1
3 0
3 1
3 2

result:

ok 30 lines

Test #10:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

20
DLDLDLDLLLDLLDLDLDLR

output:

108
-10 -8
-10 -7
-10 -6
-10 -5
-10 -4
-10 -3
-10 -2
-10 -1
-10 0
-9 -8
-9 -7
-9 -6
-9 -5
-9 -4
-9 -3
-9 -2
-9 -1
-9 0
-8 -8
-8 -7
-8 -6
-8 -5
-8 -4
-8 -3
-8 -2
-8 -1
-8 0
-7 -8
-7 -7
-7 -6
-7 -5
-7 -4
-7 -3
-7 -2
-7 -1
-7 0
-6 -8
-6 -7
-6 -6
-6 -5
-6 -4
-6 -3
-6 -2
-6 -1
-6 0
-5 -8
-5 -7
-5 -6
-5 -...

result:

ok 109 lines

Extra Test:

score: 0
Extra Test Passed