Emag eht htiw Em Pleh(模拟法)

来源:互联网 发布:python urlencode gbk 编辑:程序博客网 时间:2024/06/05 12:43
Emag eht htiw Em Pleh
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 3424 Accepted: 2249

Description

This problem is a reverse case of the problem 2996. You are given the output of the problem H and your task is to find the corresponding input.

Input

according to output of problem 2996.

Output

according to input of problem 2996.

Sample Input

White: Ke1,Qd1,Ra1,Rh1,Bc1,Bf1,Nb1,a2,c2,d2,f2,g2,h2,a3,e4Black: Ke8,Qd8,Ra8,Rh8,Bc8,Ng8,Nc6,a7,b7,c7,d7,e7,f7,h7,h6

Sample Output

+---+---+---+---+---+---+---+---+|.r.|:::|.b.|:q:|.k.|:::|.n.|:r:|+---+---+---+---+---+---+---+---+|:p:|.p.|:p:|.p.|:p:|.p.|:::|.p.|+---+---+---+---+---+---+---+---+|...|:::|.n.|:::|...|:::|...|:p:|+---+---+---+---+---+---+---+---+|:::|...|:::|...|:::|...|:::|...|+---+---+---+---+---+---+---+---+|...|:::|...|:::|.P.|:::|...|:::|+---+---+---+---+---+---+---+---+|:P:|...|:::|...|:::|...|:::|...|+---+---+---+---+---+---+---+---+|.P.|:::|.P.|:P:|...|:P:|.P.|:P:|+---+---+---+---+---+---+---+---+|:R:|.N.|:B:|.Q.|:K:|.B.|:::|.R.|+---+---+---+---+---+---+---+---+

Source

CTU Open 2005

解题报告:这是一道模拟题,以国际象棋为背景,给我们分别描述白棋和黑棋的位置,让我们在固定的格式中填充,我们首先把图表打出来(在没有白棋和黑棋的情况下),在根据所给的信息,填充即可,剩下的就是找规律了

#include <iostream>#include <cstring>#include <cstdio>using namespace std; string w1,w,b1,b;//白色是大写char mp[100][100]={                  "+---+---+---+---+---+---+---+---+",                  "|...|:::|...|:::|...|:::|...|:::|",                  "+---+---+---+---+---+---+---+---+",                  "|:::|...|:::|...|:::|...|:::|...|",                  "+---+---+---+---+---+---+---+---+",                  "|...|:::|...|:::|...|:::|...|:::|",                  "+---+---+---+---+---+---+---+---+",                  "|:::|...|:::|...|:::|...|:::|...|",                  "+---+---+---+---+---+---+---+---+",                  "|...|:::|...|:::|...|:::|...|:::|",                  "+---+---+---+---+---+---+---+---+",                  "|:::|...|:::|...|:::|...|:::|...|",                  "+---+---+---+---+---+---+---+---+",                  "|...|:::|...|:::|...|:::|...|:.:|",                  "+---+---+---+---+---+---+---+---+",                  "|:::|...|:::|...|:::|...|:::|...|",                  "+---+---+---+---+---+---+---+---+"};void chuliw(){    int i;    int x,y;//找出横纵坐标的规律,进行替换    char c;    for(i=0;w[i];i++)    {        switch(w[i])        {      case 'K':        c='K';        i++;        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        break;      case 'Q':        c='Q';        i++;        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        break;      case 'R':        c='R';        i++;        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        break;      case 'B':        c='B';        i++;        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        break;      case 'N':        c='N';        i++;        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        break;        }        if('a'<=w[i]&&w[i]<='z')        {        c='P';        y=(w[i]-'a'+1)*4-2;        i++;        x=(17-2*(w[i]-'0'));        mp[x][y]=c;        }    }}void chulib(){    int i;    int x,y;    char c;    for(i=0;b[i];i++)    {        switch(b[i])        {      case 'K':        c='k';        i++;        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        break;      case 'Q':        c='q';        i++;        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        break;      case 'R':        c='r';        i++;        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        break;      case 'B':        c='b';        i++;        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        break;      case 'N':        c='n';        i++;        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        break;        }        if('a'<=b[i]&&b[i]<='z')        {        c='p';        y=(b[i]-'a'+1)*4-2;        i++;        x=(17-2*(b[i]-'0'));        mp[x][y]=c;        }    }}int main(){    int i,j;    cin>>w1>>w>>b1>>b;    chuliw();    chulib();    for(i=0;i<17;i++)    {        for(j=0;j<33;j++)        {            cout<<mp[i][j];        }        cout<<endl;    }    return 0;}


0 0
原创粉丝点击