AOJ 0266 Aka-beko and 40 Thieves
こんにちは川です。
今回は、行く方向を示す配列を作って現在地を示しただけなので
特に言うことはないです。
#include<bits/stdc++.h>
using
namespace
std;
int
serch(
int
go,
int
now)
{
int
direction[6][2]={{1,2},{-1,3},{1,-1},{4,5},{5,2},{2,1}};
if
(now==-1)
return
-1;
return
direction[now][go];
}
int
main()
{
string str;
while
(cin>>str&&str!=
"#"
){
int
now=0;
for
(
int
i=0;i<str.size();i++)now=serch(str[i]-
'0'
,now);
if
(now==5)cout<<
"Yes\n"
;
else
cout<<
"No\n"
;
}
}