模拟 POJ 2993 Emag eht htiw Em Pleh
题目地址:http://poj.org/problem?id=2993
/*
题意:与POJ2996完全相反
模拟题 + 字符串处理:无算法,读入两行字符串找出相应点用used标记,输出时标记过的输出字母,否则输出'.'或':'。
注意:棋盘的行的顺序是从下到上递增的
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <map>
#include <queue>
#include <vector>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int used[MAXN][MAXN];
char a[MAXN][MAXN];
map<char, int> m;
string s1,s2; void print(int tw, int tb)
{
bool flag = false;
for (int i=; i<=; ++i)
{
cout << "+---+---+---+---+---+---+---+---+" << endl;
cout << "|";
flag = !flag;
for (int j=; j<=; ++j)
{
(flag) ? cout << "." : cout << ":";
if (!used[i][j]) (flag) ? cout << "." : cout << ":";
else
{
cout << a[i][j];
}
(flag) ? cout << "." : cout << ":";
flag = !flag;
cout << "|";
}
cout << endl;
} cout << "+---+---+---+---+---+---+---+---+" << endl;
} void work(void)
{
int tw = , tb = ;
for (int i=; s1[i]!='\0'; ++i) //White
{
if (s1[i] == ',') continue;
if (s1[i]<='S' && s1[i] >= 'B')
{
a[-(s1[i+]-'')][m[s1[i+]]] = s1[i];
used[-(s1[i+]-'')][m[s1[i+]]] = ;
i += ;
}
if (s1[i]<='s' && s1[i]>='a')
{
a[-(s1[i+]-'')][m[s1[i]]] = 'P';
used[-(s1[i+]-'')][m[s1[i]]] = ;
i += ;
}
if (i >= s1.size ()) break;
}
for (int i=; s2[i]!='\0'; ++i) //Black
{
if (s2[i] == ',') continue;
if (s2[i]<='S' && s2[i] >= 'B')
{
a[-(s2[i+]-'')][m[s2[i+]]] = s2[i] - 'A' + 'a';
used[-(s2[i+]-'')][m[s2[i+]]] = ;
i += ;
}
if (s2[i]<='s' && s2[i]>='a')
{
a[-(s2[i+]-'')][m[s2[i]]] = 'p';
used[-(s2[i+]-'')][m[s2[i]]] = ;
i += ;
}
if (i >= s2.size ()) break;
} print (tw, tb);
} int main(void) //POJ 2993 Emag eht htiw Em Pleh
{
//freopen ("J.in", "r", stdin); char ch = 'a';
for (int i=; i<=; ++i)
{
m[ch++] = i;
} getline (cin, s1);
getline (cin, s2);
memset (used, , sizeof (used));
work (); return ;
} /*
+---+---+---+---+---+---+---+---+
*/ /*
+---+---+---+---+---+---+---+---+
|.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.|
+---+---+---+---+---+---+---+---+
*/
模拟 POJ 2993 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 ...
- 快速切题 poj 2993 Emag eht htiw Em Pleh 模拟 难度:0
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2806 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 ...
- poj 2993 Emag eht htiw Em Pleh(模拟)
题目:http://poj.org/problem?id=2993 题意:和2996反着 #include <iostream> #include<cstdio> #inclu ...
- 模拟 + 打表 --- Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2578 Accepted: ...
- POJ 2993:Emag eht htiw Em Pleh
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536KB 64bit IO Format: %I64d & %I64 ...
- 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: ...
- 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 ...
- Emag eht htiw Em Pleh(imitate)
Emag eht htiw Em Pleh Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2901 Accepted: ...
随机推荐
- PHP引用(&)初探:函数的引用返回
函数的引用返回 先看代码: <?php function &test() { static $b=0;//申明一个静态变量 $b=$b+1; echo $b; return $b; } ...
- 新一代 Tor发布,它牛在哪里?
导读 知名匿名搜索引擎Tor,最近发布了基于火狐浏览器45-ESR的6.0版本,增强了对HTML5的支持,并更新了用来保护加密流量及其更新机制的安全功能.火狐45-ESR版本的全称为Firefox E ...
- 百度图片爬虫-python版-如何爬取百度图片?
上一篇我写了如何爬取百度网盘的爬虫,在这里还是重温一下,把链接附上: http://www.cnblogs.com/huangxie/p/5473273.html 这一篇我想写写如何爬取百度图片的爬虫 ...
- 【leetcode】4Sum
4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d ...
- 【转】自动实时监控Windows2003服务器终端登录并发邮件和发短信通知
记得以前管理的一批windows服务器,一些开源程序做的web站点总会遭到入侵.然而就想找找看有没有办法可以知道服务器有没有被入侵.服务器在什么时候登陆过,如果登陆马上发邮件通知,感觉这种问题肯定有人 ...
- eclipse的c++工程开启c++11
右击工程->Properties->C/C++ Builder->Setting->Tool Setting->Miscellanous->Other Flags添 ...
- centos 单独安装PHP的mysql和mysqli扩展
2013年11月22日 11:25:41 Linux centos 6.3 最小化安装 mysql 5.5 php 5.4 安装PHP时只是 ./configure --prefix=/**** 并没 ...
- ini 文件操作记要(1): 使用 TIniFile
ini 文件操作记要(1): 使用 TIniFile unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Class ...
- Java for LeetCode 143 Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You must do th ...
- Java创建Web项目
首先下载Tomcat服务,用来运行JAVA程序,跟windows中的IIS类似 下载地址:tomcat.apache.org ,最好下载ZIP压缩版的,解压后就可以直接用.如下图: 检查Tomcat是 ...