QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#792021 | #7516. Robot Experiment | wayya | WA | 1ms | 4036kb | C++14 | 3.9kb | 2024-11-28 22:54:16 | 2024-11-28 22:54:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
int f[110][110];
int q[110][110],w[110][110];
int bj[110][110];
int dx[4]={-1,1,0,0},dy[4]={0,0,1,-1};
char a;
string s;
void explore(int x,int y)
{
q[x+40][y+40]=1;
w[x+40][y+40]=-1;
cnt=1;
for(int i=0;i<n;i++)
{
int startx=0,starty=0;
a=s[i];
if(a=='L')
{
for(int j=1;j<=100;j++)
{
for(int k=1;k<=100;k++)
{
if(q[j][k]==1)
{
if(bj[j][k]==1) continue;
else if(f[j][k]==2&&w[j][k]==i-1)
{
q[j][k]=0;
startx=j+dx[0],starty=k+dy[0];
f[startx][starty]=1;
w[startx][starty]=i;
q[startx][starty]=1;
cnt--;
}
else
{
startx=j+dx[0],starty=k+dy[0];
if(f[startx][starty]==0)
{
cnt++;
f[startx][starty]=1;
q[startx][starty]=1;
w[startx][starty]=i;
bj[startx][starty]=1;
}
}
}
}
}
memset(bj,0,sizeof bj);
}
if(a=='R')
{
for(int j=1;j<=100;j++)
{
for(int k=1;k<=100;k++)
{
if(q[j][k]==1)
{
//cout<<f[39][40]<<" "<<w[39][40]<<" "<<q[39][40]<<'\n';
if(bj[j][k]==1) continue;
else if(f[j][k]==1&&w[j][k]==i-1)
{
q[j][k]=0;
startx=j+dx[1],starty=k+dy[1];
f[startx][starty]=2;
w[startx][starty]=i;
q[startx][starty]=1;
cnt--;
}
else
{
startx=j+dx[1],starty=k+dy[1];
if(f[startx][starty]==0)
{
cnt++;
f[startx][starty]=2;
q[startx][starty]=1;
w[startx][starty]=i;
bj[startx][starty]=1;
}
}
}
}
}
memset(bj,0,sizeof bj);
}
if(a=='U')
{
for(int j=1;j<=100;j++)
{
for(int k=1;k<=100;k++)
{
if(q[j][k]==1)
{
if(bj[j][k]==1) continue;
else if(f[j][k]==4&&w[j][k]==i-1)
{
q[j][k]=0;
startx=j+dx[2],starty=k+dy[2];
f[startx][starty]=3;
w[startx][starty]=i;
q[startx][starty]=1;
cnt--;
}
else
{
startx=j+dx[2],starty=k+dy[2];
if(f[startx][starty]==0)
{
cnt++;
f[startx][starty]=3;
q[startx][starty]=1;
w[startx][starty]=i;
bj[startx][starty]=1;
}
}
}
}
}
memset(bj,0,sizeof bj);
}
if(a=='D')
{
for(int j=1;j<=100;j++)
{
for(int k=1;k<=100;k++)
{
if(q[j][k]==1)
{
//cout<<f[41][41]<<" "<<w[41][41]<<" "<<q[41][41]<<'\n';
if(bj[j][k]==1) continue;
else if(f[j][k]==3&&w[j][k]==i-1)
{
q[j][k]=0;
startx=j+dx[3],starty=k+dy[3];
f[startx][starty]=4;
w[startx][starty]=i;
q[startx][starty]=1;
cnt--;
}
else
{
startx=j+dx[3],starty=k+dy[3];
if(f[startx][starty]==0)
{
cnt++;
f[startx][starty]=4;
q[startx][starty]=1;
w[startx][starty]=i;
bj[startx][starty]=1;
}
}
}
}
}
memset(bj,0,sizeof bj);
}
}
}
int main()
{
//freopen("explore.in","r",stdin);
//freopen("explore.out","w",stdout);
scanf("%d",&n);
cin>>s;
explore(0,0);
printf("%d\n",cnt);
///*
for(int i=0;i<=100;i++)
{
for(int j=0;j<=100;j++)
{
if(q[i][j]==1)
{
int h=i-40;
int z=j-40;
printf("%d %d\n",h,z);
}
}
}
//*/
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3952kb
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: 3844kb
input:
4 LRUD
output:
4 0 -1 0 0 1 -1 1 0
result:
ok 5 lines
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 4036kb
input:
20 LLLRLRLRLLLRLLRLRLLR
output:
-9 -6 0 -3 0 -1 0
result:
wrong answer 1st lines differ - expected: '8', found: '-9'