QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#239301#7516. Robot ExperimentHarry27182WA 170ms3584kbC++141.1kb2023-11-04 19:56:082023-11-04 19:56:08

Judging History

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

  • [2023-11-04 19:56:08]
  • 评测
  • 测评结果:WA
  • 用时:170ms
  • 内存:3584kb
  • [2023-11-04 19:56:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,ban[105][105];vector<pair<int,int> >ans;char s[25];
int main()
{
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>s;
    for(int i=0;i<(1<<n);i++)
    {
    	int x=0,y=0;
    	for(int j=0;j<n;j++)
    	{
    		int nx=x,ny=y;
    		if(s[j]=='L')nx--;
			if(s[j]=='R')nx++;
			if(s[j]=='U')ny++;
			if(s[j]=='D')ny--;
    		if(i&(1<<j))x=nx,y=ny;
			else ban[nx+20][ny+20]=1;
		}
		x=0;y=0;int flag=1;
		for(int j=0;j<n;j++)
		{
			int nx=x,ny=y;
			if(ban[x+20][y+20])flag=0;
    		if(s[j]=='L')nx--;
			if(s[j]=='R')nx++;
			if(s[j]=='U')ny++;
			if(s[j]=='D')ny--;
    		if(i&(1<<j))x=nx,y=ny;
		}
		if(ban[x][y])flag=0;
		x=0;y=0;
		for(int j=0;j<n;j++)
    	{
    		int nx=x,ny=y;
    		if(s[j]=='L')nx--;
			if(s[j]=='R')nx++;
			if(s[j]=='U')ny++;
			if(s[j]=='D')ny--;
    		if(i&(1<<j))x=nx,y=ny;
			else ban[nx+20][ny+20]=0;
		}
		if(flag)ans.emplace_back(make_pair(x,y));
	}
	sort(ans.begin(),ans.end());
	int pos=unique(ans.begin(),ans.end())-ans.begin();
	cout<<pos<<'\n';
	for(int i=0;i<pos;i++)cout<<ans[i].first<<' '<<ans[i].second<<'\n';
	return 0;
}

详细

Test #1:

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

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

input:

4
LRUD

output:

4
0 -1
0 0
1 -1
1 0

result:

ok 5 lines

Test #3:

score: -100
Wrong Answer
time: 170ms
memory: 3564kb

input:

20
LLLRLRLRLLLRLLRLRLLR

output:

6
-6 0
-5 0
-4 0
-3 0
0 0
1 0

result:

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