QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239298#7516. Robot ExperimentHarry27182WA 0ms3560kbC++141.1kb2023-11-04 19:55:442023-11-04 19:55:45

Judging History

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

  • [2023-11-04 19:55:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2023-11-04 19:55:44]
  • 提交

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();
	for(int i=0;i<pos;i++)cout<<ans[i].first<<' '<<ans[i].second<<'\n';
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

input:

2
RU

output:

0 0
0 1
1 0
1 1

result:

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