QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#792020 | #7516. Robot Experiment | gaojiaxuan | RE | 0ms | 0kb | C++14 | 1.8kb | 2024-11-28 22:54:00 | 2024-11-28 22:54:08 |
answer
#include<bits/stdc++.h>
using namespace std;
bool g[22][22];
int bxxl[22][3];
int main()
{
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
string s;
int n;
cin>>n>>s;
if(n==1)
{
cout<<"2"<<endl<<"0 0"<<endl;
if(s=="L")cout<<"-1 0";
if(s=="R")cout<<"1 0";
if(s=="U")cout<<"0 1";
if(s=="D")cout<<"0 -1";
return 0;
}
if(n==2)
{
if(s[0]==s[1])
{
cout<<"3"<<endl<<"0 0"<<endl;
if(s=="LL")cout<<"-1 0"<<endl<<"-2 0";
if(s=="RR")cout<<"1 0"<<endl<<"2 0";
if(s=="UU")cout<<"0 1"<<endl<<"0 2";
if(s=="DD")cout<<"0 -1"<<endl<<"0 -2";
return 0;
}
if(s=="LR"||s=="RL"||s=="UD"||s=="DU")
{
cout<<"2"<<endl<<"0 0"<<endl;
if(s=="LR")cout<<"1 0";
if(s=="RL")cout<<"-1 0";
if(s=="UD")cout<<"0 -1";
if(s=="DU")cout<<"0 1";
return 0;
}
if(s[0]!=s[1]&&(s!="LR"||s!="RL"||s!="UD"||s!="DU"))
{
cout<<"4"<<endl<<"0 0"<<endl;
if(s=="LU")cout<<"-1 0"<<endl<<"0 1"<<endl<<"-1 1";
if(s=="LD")cout<<"-1 0"<<endl<<"0 -1"<<endl<<"-1 -1";
if(s=="RU")cout<<"0 1"<<endl<<"1 0"<<endl<<"1 1";
if(s=="RD")cout<<"1 0"<<endl<<"0 -1"<<endl<<"1 -1";
return 0;
}
}
if(n!=1&&n!=2)
{
int cnt=0,l=s.size();
g[0][0]=1;
int x=0,y=0;
for(int i=0;i<l;i++)
{
if(i+1<l&&((s[i]=='R'&&s[i+1]=='L')||(s[i]=='L'&&s[i+1]=='R')||(s[i]=='U'&&s[i+1]=='D')||(s[i]=='D'&&s[i+1]=='U')))
{
continue;
}
else
{
if(s[i]=='L')x=x-1;
if(s[i]=='R')x=x+1;
if(s[i]=='U')y=y+1;
if(s[i]=='D')y=y-1;
g[x][y]=1;
bxxl[i][1]=x,bxxl[i][2]=y;
}
}
for(int i=-22;i<=22;i++)
{
for(int j=-22;j<=22;j++)
{
if(g[i][j]==1)cnt++;
}
}
cout<<cnt<<endl;
for(int i=0;i<l;i++)
{
cout<<bxxl[i][1]<<" "<<bxxl[i][2]<<endl;
}
return 0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 RU