QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548690#7516. Robot ExperimentStelorWA 1ms3660kbC++17859b2024-09-05 20:09:482024-09-05 20:09:48

Judging History

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

  • [2024-09-05 20:09:48]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3660kb
  • [2024-09-05 20:09:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<array<int,3>,int> mp;
vector<pair<int,int>> ans;
void dfs(int x,int y,int now)
{
	if(mp.count({x,y,now})) return;
	if(now==n+1) 
	{
		ans.push_back({x,y});
		return;
	}
	mp[{x,y,now}]=1;
	dfs(x,y,now+1);
	if(s[now]=='L')
	{
		dfs(x-1,y,now+1);
	}
	else if(s[now]=='R')
	{
		dfs(x+1,y,now+1);
	}
	else if(s[now]=='U') 
	{
		dfs(x,y+1,now+1);
	}
	else if(s[now]=='D')
	{
		dfs(x,y-1,now+1);
	}
}
void solve()
{
	cin>>n>>s;
	s="#"+s;
	dfs(0,0,1); 
	sort(ans.begin(),ans.end(),[&](auto u,auto j)
	{
	    if(u.first==u.second) return u.second<j.second;
		else return u.first<j.second;	
	});
	cout<<ans.size()<<'\n';
	for(auto [i,j]:ans) 
	{
		cout<<i<<" "<<j<<"\n";
	}
}
int main()
{
	ios::sync_with_stdio(0),cin.tie(0);
	solve();
	return 0; 
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

input:

2
RU

output:

4
0 0
0 1
1 0
1 1

result:

ok 5 lines

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3560kb

input:

4
LRUD

output:

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

result:

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