传送门:http://codeforces.com/contest/1089/problem/E
思路:快乐暴力打表,-2步判断,因为会有一步就能到达的情况
代码:
#include<bits/stdc++.h>
using namespace std;
using ll=long long ;
const int maxn=1e5+6;
int a[49]={-1,1,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,
1,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,
1,8,8,7,7,6,6,5,5,4,4,3,3,2,2,1,
};
int b[49]={-1,1,1,2,2,1,1,2,2,1,1,2,2,1,1,2,2,
3,3,4,4,3,3,4,4,3,3,4,4,3,3,4,4,
5,5,6,6,5,5,6,6,5,5,6,6,5,5,6,6,
};
int c[17]={0,1,2,3,4,5,6,8,7,7,6,5,4,3,2,1,8};
int d[17]={0,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8};
int main(){
int n;
scanf("%d",&n);
n++;
if(n==2){
printf("a1 h1 h8\n");
}
else
{
int t=n-2;
if(t<=48)
{
int xx=a[t];
int yy=b[t];
for(int j=1;j<=t;j++)
{
printf("%c%d ",a[j]+96,b[j]);
}
if(xx==8)
{
printf("h7 h8\n");
}
else
{
printf("%c%d h8\n",xx+96,8);
}
}
else
{
int xx=c[t-48];
int yy=d[t-48];
for(int j=1;j<=48;j++)
{
printf("%c%d ",a[j]+96,b[j]);
}
if(xx==8&&yy==7)
{
for(int i=1;i<=t-49;i++)
{
printf("%c%d ",c[i]+96,d[i]);
}
printf("g7 g8 h8\n");
}
else if(xx==7&&yy==7)
{
for(int i=1;i<=t-48;i++)
{
printf("%c%d ",c[i]+96,d[i]);
}
printf("g8 h8\n");
}
else if(yy==7)
{
for(int i=1;i<=t-48;i++)
{
printf("%c%d ",c[i]+96,d[i]);
}
printf("h7 h8\n");
}
else
{
for(int i=1;i<=t-48;i++)
{
printf("%c%d ",c[i]+96,d[i]);
}
printf("a8 h8\n");
}
}
}
}