【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: ...
随机推荐
- 转:更改pip源至国内镜像,显著提升下载速度
经常在使用python的时候需要安装各种模块,而pip是很强大的模块安装工具,但是由于国外官方pypi经常被墙,导致不可用,所以我们最好是将自己使用的pip源更换一下,这样就能解决被墙导致的装不上库的 ...
- Java知识回顾 (17)MySQL链接
本部分介绍如何使用JDBC 连接 MySQL 数据库. 驱动包下载 Java 连接 MySQL 需要驱动包,最新版下载地址为:http://dev.mysql.com/downloads/connec ...
- ondblclick和dblclick区别
1.ondblclick是一个HTML DOM Event 对象,没有jquery也可以触发这个事件的,使用方法例如 1 <button ondblclick="xxx"&g ...
- ss-套接字监控工具
ss(Socket Statistics) - another utility to investigate sockets(研究套接字的另一个实用程序,原先的是netstat) ss用于转储套接字统 ...
- MySQL优化整理
一.SQL优化 1.show status查看各种sql的执行频率 SHOW STATUS 可以根据需要显示 session 级别的统计结果和 global级别的统计结果. 显示当前sessi ...
- MySQL安装-glibc方式安装
MySQL安装-glibc方式安装 版本说明:这里安装版本为MySQL-5.7系列的 mysql-5.7.27-linux-glibc2.12-x86_64.tar.gz 步骤 下载软件包 官网下载 ...
- 使用Arduino开发板连接干簧管(Reed Switch)的方法
在现实生活中,干簧管(Reed Switch)有许多重要的应用,如磁性门开关.笔记本电脑.智能手机等.在本篇文章中,我们将了解一些干簧管的知识,并介绍如何使用Arduino开发板连接干簧管. 干簧管( ...
- springboot 2.x整合redis,spring aop实现接口缓存
pox.xml: <dependency> <groupId>org.springframework.boot</groupId> <artifactId&g ...
- 使用gitlab下载代码(附常用命令)
Git是现在很多人常用的代码管理工具,这里有一些常用的命令详解,本人接触也不是很久,若有错误,请在评论指出,谢谢. 若计算机中没有安装GIT,可自行查找安装教程,十分简便. ①首先,我们需要下载项目, ...
- 深度学习Keras框架笔记之核心层基类
Keras的Layers,就是构成网络的每一层.Keras实现了很多层,包括核心层.卷基层.RNN网络层等诸多常用的网络结构.下面开介绍核心层中包含了哪些内容.因为这个核心层我现在还没有全部用到,所以 ...