传送门
最近代码能力急剧下降,所以开始刷大模拟
这道题坑点很多,细节都在代码注释里了
code:
#include<bits/stdc++.h>
using namespace std;
inline int read(){
register int s=0,f=1;
register char ch=getchar();
while(!isdigit(ch)){
if(ch=='-')f*=-1;ch=getchar();}
while(isdigit(ch))s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
return s*f;
}
const int captain[20][5]={
{
0,1},{
1,0},{
0,-1},{
-1,0}
};
const int guard[20][5]={
{
1,1},{
1,-1},{
-1,1},{
-1,-1}
};
const int elephant[20][5]={
{
2,-2},{
-2,2},{
2,2},{
-2,-2}
};
const int Elephant[20][5]={
{
1,-1},{
-1,1},{
1,1},{
-1,-1}
};
const int horse[20][5]={
{
2,-1},{
2,1},{
1,2},{
-1,2},{
-2,1},{
-2,-1},{
-1,-2},{
1,-2}
};
const int Horse[20][5]={
{
1,0},{
1,0},{
0,1},{
0,1},{
-1,0},{
-1,0},{
0,-1},{
0,-1}
};
const int duck[20][5]={
{
3,2},{
-3,2},{
2,3},{
2,-3},{
3,-2},{
-3,-2},{
-2,3},{
-2,-3}
};
const int Duck[20][5]={
{
1,0},{
-1,0},{
0,1},{
0,-1},{
1,0},{
-1,0},{
0,1},{
0,-1},
{
2,1},{
-2,1},{
1,2},{
1,-2},{
2,-1},{
-2,-1},{
-1,2},{
-1,-2}
};
const int soldier[20][5]={
{
0,1},{
1,0},{
0,-1},{
-1,0},{
1,1},{
-1,-1},{
1,-1},{
-1,1}
};
//每个子的走法如上
int color,End,flg;
int a[20][20],h[20][20];
string f[10];
void Clean(){
f[1]="captain";f[2]="guard";
f[3]="elephant";f[4]="horse";
f[5]="car";f[6]="duck";f[7]="soldier";//数字对应棋子
a[1][1]=a[1][9]=5,h[1][1]=h[1][9]=1;
a[1][2]=a[1][8]=4,h[1][2]=h[1][8]=1;
a[1][3]=a[1][7]=3,h[1][3]=h[1][7]=1;
a[1][4]=a[1]