QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#239301 | #7516. Robot Experiment | Harry27182 | WA | 170ms | 3584kb | C++14 | 1.1kb | 2023-11-04 19:56:08 | 2023-11-04 19:56:08 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'