【POJ2993】Emag eht htiw Em Pleh
本题知识点:模拟(如果对国际象棋不熟悉的同学可以先百度一下)
本题跟POJ2996是逆过来的操作,如果做过【POJ2996】的同学就不会对题意不理解的了。
(以下默认您已AC【POJ2996】)
个人觉得该题比【POJ2996】要麻烦一点,因为要创建一个棋盘(其实也不是什么麻烦事)
创好棋盘后,再把棋子一个个地放回去就可以了,这步操作跟【POJ2996】有异曲同工之妙
数据很小(快乐水题)
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
const int H = 17;
const int W = 33;
char chess[40][40];
string white, black;
struct node{
string pla;
}w[20], b[20];
void build(){
for(int i = 1; i <= H; i++){
if(i % 2 == 1){
for(int j = 1; j <= W; j++){
if(j % 4 == 1) chess[i][j] = '+';
else chess[i][j] = '-';
}
}
else if(i % 4 == 2){
for(int j = 1; j <= W; ){
if(j % 4 == 1) {
chess[i][j] = '|';
j += 3;
}
else {
if(j % 8 == 4){
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = '.';
j++;
}
else {
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = ':';
j++;
}
}
}
}
else if(i % 2 == 0){
for(int j = 1; j <= W; ){
if(j % 4 == 1) {
chess[i][j] = '|';
j += 3;
}
else {
if(j % 8 == 4){
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = ':';
j++;
}
else {
chess[i][j] = chess[i][j - 1] = chess[i][j - 2] = '.';
j++;
}
}
}
}
}
}
char turn(char x){
if('A' <= x && x <= 'Z')
x += 32;
return x;
}
int main()
{
build();
getline(cin, white);
// White
int cnt_w = 0, h, w;
for(int i = 7; i < white.size(); ){
if(white[i] == 'K' || white[i] == 'Q' || white[i] == 'R' || white[i] == 'B' || white[i] == 'N'){
w = (white[i + 1] - 'a') * 4 + 3;
char ch = white[i + 2];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = white[i];
i += 4;
}
else {
w = (white[i] - 'a') * 4 + 3;
char ch = white[i + 1];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = 'P';
i += 3;
}
}
getline(cin, black);
// Black
int cnt_b = 0;
for(int i = 7; i < black.size(); ){
if(black[i] == 'K' || black[i] == 'Q' || black[i] == 'R' || black[i] == 'B' || black[i] == 'N'){
w = (black[i + 1] - 'a') * 4 + 3;
char ch = black[i + 2];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
char b = turn(black[i]);
chess[h][w] = b;
i += 4;
}
else {
w = (black[i] - 'a') * 4 + 3;
char ch = black[i + 1];
if(ch == '1') h = 16;
else if(ch == '2') h = 14;
else if(ch == '3') h = 12;
else if(ch == '4') h = 10;
else if(ch == '5') h = 8;
else if(ch == '6') h = 6;
else if(ch == '7') h = 4;
else if(ch == '8') h = 2;
chess[h][w] = 'p';
i += 3;
}
}
for(int i = 1; i <= H; i++) printf("%s\n", chess[i] + 1);
return 0;
}
【POJ2993】Emag eht htiw Em Pleh的更多相关文章
- POJ 2993 Emag eht htiw Em Pleh【模拟画棋盘】
链接: http://poj.org/problem?id=2993 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=27454#probl ...
- POJ2993——Emag eht htiw Em Pleh(字符串处理+排序)
Emag eht htiw Em Pleh DescriptionThis problem is a reverse case of the problem 2996. You are given t ...
- 模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2578 Accepted: ...
- Emag eht htiw Em Pleh(imitate)
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2901 Accepted: ...
- 模拟 POJ 2993 Emag eht htiw Em Pleh
题目地址:http://poj.org/problem?id=2993 /* 题意:与POJ2996完全相反 模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出 ...
- Emag eht htiw Em Pleh 分类: POJ 2015-06-29 18:54 10人阅读 评论(0) 收藏
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2937 Accepted: ...
- 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 ...
- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh This problem is a reverse case of the problem 2996. You are given the output o ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 Accepted: ...
随机推荐
- python程序打包exe文件
第一步:安装依赖 pip install pyinstaller 第二步:移动文件 把python文件和一个exe拿来当图标的ico文件移动到同一文件中 注意:文件路径不用用中文!!!!!!!! 第三 ...
- np.newaxis的使用及有趣的数组相乘
a=np.array([1,2,3,4])a=a[np.newaxis,:] #固定行,相当于1行多列b=np.array([2,4,6]) b=b[:,np.newaxis] #固定列,相当与多行1 ...
- 关于zynq系列板卡设计VREFP_0参考电压的疑问及解答
使用板卡:Z-turn Board 芯片:Xilinx Zynq-7010/7020处理器 有工程师在试用zynq系列Z-turn Board时提出:在原理图P3页 Bank0上VREFP_0端接地的 ...
- 【面试突击】-Redis常见面试题(二)
1.什么是Redis?简述它的优缺点? Redis本质上是一个Key-Value类型的内存数据库,很像memcached,整个数据库统统加载在内存当中进行操作,定期通过异步操作把数据库数据flush到 ...
- Git管理修正(取消跟踪、合并commit)
本文总结了最近使用Git时候遇到的两个问题: 1. 当将不必要跟踪的文件加入到仓库后如何处理? 2. 提交了多个功能相同的commit后如何处理? 总结经验 在创建仓库的一开始,就要设置号.gitig ...
- 图说jdk1.8新特性(3)--- 注解与类型推测优化
获取同一类型多个注解 jdk1.8的java.lang.Class类新增了方法getAnnotationsByType方法,该方法可以获取某一个类型的注解列表,具体代码示例如下: public c ...
- Netlink: 内核与用户空间传输数据的socket协议
https://en.wikipedia.org/wiki/Netlink https://stackoverflow.com/questions/12899055/how-kernel-notify ...
- OpenStack核心组件-keystone
1. Keystone介绍 keystone是OpenStack的组件之一,用于为OpenStack家族中的其它组件成员提供统一的认证服务,包括身份验证.令牌的发放和校验.服务列表.用户权限的定义等等 ...
- PHP开启慢日志查询
1.找到php-fpm.conf文件 2.去掉request_slowlog_timeout前面的分号,并设置时间.如:request_slowlog_timeout=5表示超过5秒的 慢日志文件位置 ...
- nginx: [error] invalid PID number "" in "/run/nginx.pid"
在重启云主机(系统)之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错 nginx: [error] invalid PID number “” in “/ ...