QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#192004 | #7516. Robot Experiment | ucup-team1448# | WA | 0ms | 3948kb | C++14 | 1.5kb | 2023-09-30 13:16:51 | 2023-09-30 13:16:52 |
Judging History
answer
//#define dxx
#ifdef dxx
#define dbg(...) fprintf(stderr,__VA_ARGS__)
#define dex(a) dbg(#a"=%lld onL%d infun %s\n",a,__LINE__,__FUNCTION__)
#include<cstdlib>
#define pause sys##tem("pause")
#define _GLIBCXX_DEBUG
#endif
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using ll=long long;
using std::max;
using std::min;
using std::abs;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}
template<class T> T sqr(T a){return a*a;}
namespace xm{
const int ZERO=22;
std::set<std::pair<int,int> > st;
int N;
char seq[50];
short vis[50][50];
void dfs(int x,int y,int si){
int dx,dy,nx,ny;
if(si>N){
st.emplace(x,y);
return;
}
vis[x+ZERO][y+ZERO]=1;
if(seq[si]=='L') dx=-1,dy=0;
if(seq[si]=='R') dx=1,dy=0;
if(seq[si]=='U') dx=0,dy=1;
if(seq[si]=='D') dx=0,dy=-1;
nx=x+dx;
ny=y+dy;
if(vis[nx+ZERO][ny+ZERO]==1){
dfs(nx,ny,si+1);
}else if(!vis[nx+ZERO][ny+ZERO]){
vis[nx+ZERO][ny+ZERO]=-1;
dfs(x,y,si+1);
dfs(nx,ny,si+1);
vis[nx+ZERO][ny+ZERO]=0;
}
}void _(){
scanf("%d%s",&N,seq+1);
dfs(0,0,1);
printf("%zu\n",st.size());
for(auto pair:st) printf("%d %d\n",pair.first,pair.second);
}
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
xm::_();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
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: 3816kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3948kb
input:
20 LLLRLRLRLLLRLLRLRLLR
output:
2 -6 0 -5 0
result:
wrong answer 1st lines differ - expected: '8', found: '2'