模拟 + 打表 --- Emag eht htiw Em Pleh

Emag
eht htiw Em Pleh










Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2578   Accepted: 1731

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.|
+---+---+---+---+---+---+---+---+

【题目来源】

CTU
Open 2005

【题目大意】

这题和上一题是相关联的,上一题是给棋盘让你输出棋子的坐标,这题时给坐标让你输出棋盘。

【题目分析】

先将整个棋盘的初始状态打表存放起来,然后每次都初始化,输入坐标后更新数组的值,最后输出。

思路清晰就能1A。


#include<cstdio>
#include<cstring>
char Map[17][33];
char Graph[17][33]=
{
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,‘:‘,‘:‘,‘:‘,‘|‘,‘.‘,‘.‘,‘.‘,‘|‘,
‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,‘-‘,‘-‘,‘-‘,‘+‘,
};

void make_table()
{
for(int i=0;i<17;i++)
for(int j=0;j<33;j++)
Map[i][j]=Graph[i][j];
}

char w[500];
char b[500];

void update1(char c,char x1,char y1)
{
int x=(8-(y1-‘0‘)+1)*2-1;
int y=(x1-‘a‘+1)*4-2;
Map[x][y]=c;
}

void update2(char c,char x1,char y1)
{
int x=(8-(y1-‘0‘)+1)*2-1;
int y=(x1-‘a‘+1)*4-2;
Map[x][y]=c+32;
}

void update3(char x1,char y1)
{
int x=(8-(y1-‘0‘)+1)*2-1;
int y=(x1-‘a‘+1)*4-2;
Map[x][y]=‘P‘;
}

void update4(char x1,char y1)
{
int x=(8-(y1-‘0‘)+1)*2-1;
int y=(x1-‘a‘+1)*4-2;
Map[x][y]=‘p‘;
}

int main()
{
while(scanf("White: %s",w)!=EOF)
{
getchar();
scanf("Black: %s",b);
getchar();
make_table();
int len1=strlen(w);
int len2=strlen(b);
for(int i=0;i<len1;)
{
if(w[i]>=‘A‘&&w[i]<=‘Z‘)
{
update1(w[i],w[i+1],w[i+2]);
i+=4;
}
else if(w[i]>=‘a‘&&w[i]<=‘z‘)
{
update3(w[i],w[i+1]);
i+=3;
}
}
for(int i=0;i<len2;)
{
if(b[i]>=‘A‘&&b[i]<=‘Z‘)
{
update2(b[i],b[i+1],b[i+2]);
i+=4;
}
else if(b[i]>=‘a‘&&b[i]<=‘z‘)
{
update4(b[i],b[i+1]);
i+=3;
}
}
for(int i=0;i<17;i++)
{
for(int j=0;j<33;j++)
printf("%c",Map[i][j]);
puts("");
}
}
return 0;
}

模拟 + 打表 --- Emag eht htiw Em Pleh

时间: 2024-11-06 03:42:53

模拟 + 打表 --- Emag eht htiw Em Pleh的相关文章

快速切题 poj 2993 Emag eht htiw Em Pleh 模拟

Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2806   Accepted: 1865 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 correspond

Poj 2993 Emag eht htiw Em Pleh

1.Link: http://poj.org/problem?id=2993 2.Content: Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2801   Accepted: 1861 Description This problem is a reverse case of the problem 2996. You are given the output of the

POJ2993——Emag eht htiw Em Pleh

Emag eht htiw Em Pleh DescriptionThis 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.Inputaccording to output of problem 2996.Outputaccording to input of probl

Emag eht htiw Em Pleh(imitate)

Emag eht htiw Em Pleh Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2901   Accepted: 1917 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 correspond

POJ 2993 Emag eht htiw Em Pleh 模拟

http://poj.org/problem?id=2993 模拟大法好. 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char q[10],w[100]; 6 char e[10],r[100]; 7 char white[12]= {'K','Q','R','B','N','P'}; 8 char black[12]= {'k','q','r

POJ 2993 Emag eht htiw Em Pleh (模拟)(strtok 应用)

http://www.zhuke.com/user/zkuser48082492?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser74628816?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser8162521?1r7R=123.baidu.com&eu=&lvhttp://www.zhuke.com/user/zkuser67

poj2993(Emag eht htiw Em Pleh)

题目大意: 给你白棋子的位置: 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模拟出棋盘的情况a-h代表横坐标,1-17代表纵坐标.后面的位置首歌字符没有大写字母的是P,其中白棋子p是大写,黑棋子p是小写.解题思路:一句话太恶心,模拟一小时,我都晕了.代码: 1 #include <algorit

POJ-2993 Emag eht htiw Em Pleh---棋盘模拟

题目链接: https://vjudge.net/problem/POJ-2993 题目大意: 输入和输出和这里相反. 思路: 模拟题,没啥算法,直接模拟,不过为了代码精简,还是花了一点心思的 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cmath> 6 #include<queue> 7 #i

Linux curl 模拟form表单提交信息和文件

curl是一个命令行方式下传输数据的开源传输工具,支持多种协议:FTP.HTTP.HTTPS.IMAP.POP3.TELNET等,功能超级强大. 我今天想说的是程序开发中常用的模拟Form提交 1.GET提交 特别简单直接写url里面 2.POST提交    通过 --data/-d 方式指定使用POST方式传递数据 3.模拟form表单提交文件  --form/-F 模拟form表单提交文件 这个命令超级好用,再也不用为了写上传接口,而被迫写一个Form表单了 "[email protecte