QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#548690 | #7516. Robot Experiment | Stelor | WA | 1ms | 3660kb | C++17 | 859b | 2024-09-05 20:09:48 | 2024-09-05 20:09:48 |
Judging History
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;
}
详细
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'