您的位置:首页 > 其它

Emag eht htiw Em Pleh 分类: POJ 2015-06-29 18:54 10人阅读 评论(0) 收藏

2015-06-29 18:54 465 查看
Emag eht htiw Em Pleh

Time Limit: 1000MSMemory Limit: 65536K
Total Submissions: 2937Accepted: 1944
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,e4
Black: 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.|
+---+---+---+---+---+---+---+---+
还是模拟题
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

const int Max=1100000;

char str[]="+---+---+---+---+---+---+---+---+";
char s1[]="|:::|...|:::|...|:::|...|:::|...|";
char s2[]="|...|:::|...|:::|...|:::|...|:::|";
char Map[55][55];
void Trans(char s[])
{
bool flag=false;
if(s[0]=='B')
{
flag=true;
}
for(int i=7; s[i];)
{
if(s[i]>='A'&&s[i]<='Z')
{
int u=s[i+1]-'a'+1;
int v=s[i+2]-'0';
if(flag)
{
Map[v][u]=s[i]+32;
}
else
{
Map[v][u]=s[i];
}
i+=4;
}
else if(s[i]>='a'&&s[i]<='z')
{
int u=s[i]-'a'+1;
int v=s[i+1]-'0';
if(flag)
{
Map[v][u]='p';
}
else
{
Map[v][u]='P';
}
i+=3;
}
}
}
int main()
{
char white[110];
char black[110];
memset(white,'\0',sizeof(white));
memset(black,'\0',sizeof(black));
gets(white);
gets(black);
memset(Map,0,sizeof(Map));
Trans(white);
Trans(black);
int u=8;
for(int i=17; i>=1; i--)
{
if(i%2)
{
printf("%s\n",str);
}
else
{
int ans=2;
int v=1;
if((i/2)%2)
{
for(int j=0; j<33; j++)
{
if(j!=ans)
{
printf("%c",s1[j]);
}
else
{
if(Map[u][v])
{
printf("%c",Map[u][v]);
}
else
{
printf("%c",s1[j]);
}
v++;
ans+=4;
}
}
}
else
{
for(int j=0; j<33; j++)
{
if(j!=ans)
{
printf("%c",s2[j]);
}
else
{
if(Map[u][v])
{
printf("%c",Map[u][v]);
}
else
{
printf("%c",s2[j]);
}
v++;
ans+=4;
}
}
}
printf("\n");
u--;
}
}
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: