2018-2019 ICPC, NEERC, Northern Eurasia Finals E.Easy Chess

传送门: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");
            }
        }

    }
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值