QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#792037#7516. Robot ExperimentgaojiaxuanWA 0ms3600kbC++141.7kb2024-11-28 22:57:132024-11-28 22:57:19

Judging History

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

  • [2024-11-28 22:57:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-11-28 22:57:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool g[22][22];
int bxxl[22][3];
int main()
{
	string s;
	int n;
	cin>>n>>s;
	if(n==1)
	{
		cout<<"2"<<endl<<"0 0"<<endl;
		if(s=="L")cout<<"-1 0";
		if(s=="R")cout<<"1 0";
		if(s=="U")cout<<"0 1";
		if(s=="D")cout<<"0 -1";
		return 0;
	}
	if(n==2)
	{
		if(s[0]==s[1])
		{
			cout<<"3"<<endl<<"0 0"<<endl;
			if(s=="LL")cout<<"-1 0"<<endl<<"-2 0";
			if(s=="RR")cout<<"1 0"<<endl<<"2 0";
			if(s=="UU")cout<<"0 1"<<endl<<"0 2";
			if(s=="DD")cout<<"0 -1"<<endl<<"0 -2";
			return 0;
		}
		if(s=="LR"||s=="RL"||s=="UD"||s=="DU")
		{
			cout<<"2"<<endl<<"0 0"<<endl;
			if(s=="LR")cout<<"1 0";
			if(s=="RL")cout<<"-1 0";
			if(s=="UD")cout<<"0 -1";
			if(s=="DU")cout<<"0 1";
			return 0;
		}
		if(s[0]!=s[1]&&(s!="LR"||s!="RL"||s!="UD"||s!="DU"))
		{
			cout<<"4"<<endl<<"0 0"<<endl;
			if(s=="LU")cout<<"-1 0"<<endl<<"0 1"<<endl<<"-1 1";
			if(s=="LD")cout<<"-1 0"<<endl<<"0 -1"<<endl<<"-1 -1";
			if(s=="RU")cout<<"0 1"<<endl<<"1 0"<<endl<<"1 1";
			if(s=="RD")cout<<"1 0"<<endl<<"0 -1"<<endl<<"1 -1";
			return 0;
		}
	}
	if(n!=1&&n!=2)
	{
		int cnt=0,l=s.size();
		g[0][0]=1;
		int x=0,y=0;
		for(int i=0;i<l;i++)
		{
			if(i+1<l&&((s[i]=='R'&&s[i+1]=='L')||(s[i]=='L'&&s[i+1]=='R')||(s[i]=='U'&&s[i+1]=='D')||(s[i]=='D'&&s[i+1]=='U')))
			{
				continue;
			}
			else
			{
				if(s[i]=='L')x=x-1;
				if(s[i]=='R')x=x+1;
				if(s[i]=='U')y=y+1;
				if(s[i]=='D')y=y-1;
				g[x][y]=1;
				bxxl[i][1]=x,bxxl[i][2]=y;
			}
		}
		for(int i=-22;i<=22;i++)
		{
			for(int j=-22;j<=22;j++)
			{
				if(g[i][j]==1)cnt++;
			}
		}
		cout<<cnt<<endl;
		for(int i=0;i<l;i++)
		{
			cout<<bxxl[i][1]<<" "<<bxxl[i][2]<<endl;
		}
		return 0;
	}
	return 0;
}

详细

Test #1:

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

input:

2
RU

output:

4
0 0
0 1
1 0
1 1

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3540kb

input:

4
LRUD

output:

109
0 0
1 0
0 0
1 -1

result:

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