【习题 3-6 UVA - 232】Crossword Answers
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
模拟题。注意场宽为3
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int n, m, num[N + 10][N + 10], last[N + 10];
string s[N + 10];
int main()
{
/*freopen("F:\\rush.txt", "r", stdin);*/
int kk = 0;
while (cin >> n && n)
{
if (kk) puts("");
memset(last, 0, sizeof last);
cin >> m;
for (int i = 0; i < n; i++) cin >> s[i];
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (s[i][j]!='*' && (j == 0 || i == 0 || s[i][j - 1] == '*' || s[i - 1][j] == '*'))
num[i][j] = ++cnt;
printf("puzzle #%d:\n", ++kk);
printf("Across\n");
for (int i = 0; i < n; i++)
{
int now = 0;
for (int j = now; j < m; j++)
if (j >= now && isalpha(s[i][j]) && (j == 0 || s[i][j - 1] == '*'))
{
printf("%3d.", num[i][j]);
while (j < m && isalpha(s[i][j]))
putchar(s[i][j++]);
puts("");
now = j;
}
}
printf("Down\n");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
if (isalpha(s[i][j]) && (i == 0 || s[i - 1][j] == '*') && i >= last[j])
{
printf("%3d.", num[i][j]);
int now = i;
while (now < n && s[now][j] != '*') putchar(s[now++][j]);
last[j] = now;
puts("");
}
}
}
return 0;
}
【习题 3-6 UVA - 232】Crossword Answers的更多相关文章
- UVa 232 Crossword Answers
Crossword Answers A crossword puzzle consists of a rectangular grid of black and white squares and ...
- UVa232.Crossword Answers
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Uva 232 一个换行WA 了四次
由于UVA OJ上没有Wrong anwser,搞的多花了好长时间去测试程序,之前一直以为改OJ有WA,后来网上一搜才知道没有WA,哎哎浪费了好长时间.此博客用来记录自己的粗心大意. 链接地址:htt ...
- poj 1888 Crossword Answers 模拟题
Crossword Answers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 869 Accepted: 405 D ...
- Crossword Answers UVA - 232
题目大意 感觉挺水的一道题.找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题) 解析 ①找出各个格子的编号 ②对每个节点搜索一下 ③输出的时候注意最后一个数据后面 ...
- 紫书第三章训练1 D - Crossword Answers
A crossword puzzle consists of a rectangular grid of black and white squares and two lists of defini ...
- UVA 232 Corssword Answer
题意:输入m*n大小的字符串(里面有*,*为黑格,其他为白格),然后对它编号,编号规则为从左到右,从上往下,且左边或上面没有白格(可能是黑格或越界),如下图: 注意: ①除第一次输出答案外,其余每次输 ...
- Crossword Answers -------行与列按序输出
题目链接:https://vjudge.net/problem/UVA-232#author=0 题意:关键句:The de nitions correspond to the rectangular ...
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
随机推荐
- js---05 自定义属性
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- Lucene 定义
福利 => 每天都推送 欢迎大家,关注微信扫码并加入我的4个微信公众号: 大数据躺过的坑 Java从入门到架构师 人工智能躺过的坑 Java全栈大联盟 ...
- OpenStack安装及监控配置视频教程
OpenStack是一个美国国家航空航天局和Rackspace合作研发的云端运算软件,是一个自由软件和开放源代码项目,用来建立公共和私有云本,其软件使用比较复杂,本视频将讲解其安装和部分配置方法,以后 ...
- 【Codeforces Round #427 (Div. 2) B】The number on the board
[Link]:http://codeforces.com/contest/835 [Description] 原本有一个数字x,它的各个数码的和原本是>=k的; 现在这个数字x,在不改变位数的情 ...
- 中小型WEB系统权限日志数据表设计
中小型WEB系统权限日志数据表设计 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMjc1MDU3OA==/font/5a6L5L2T/fontsi ...
- Problem C: Celebrity Split
题目描写叙述 Problem C: Celebrity Split Jack and Jill have decided to separate and divide their property e ...
- opera mini 改服
opera mini 改服 下载 opera 和 opera mini ftp://ftp.opera.com/pub/opera/android/mini/ ftp://ftp.opera.com/ ...
- FragMent-通过Arguments方法 跟activity通信
今天主要学习下通过Arguments,实现activity 给fragment传递数据.这个方法也是通过参数bundle来进行数据传输的 直接看如下代码 一,定义一个fragment,在oncreat ...
- android图片特效处理之图片叠加
这篇将讲到图片特效处理的图片叠加效果.跟前面一样是对像素点进行处理,可参照前面的android图像处理系列之七--图片涂鸦,水印-图片叠加和android图像处理系列之六--给图片添加边框(下)-图片 ...
- CMake设置生成vs工程的动态库输出路径
作者:朱金灿 来源:http://blog.csdn.net/clever101 在网上搜了很多的资料,发现CMake不能设置一个动态库工程的输出目录和中间目录,难道除了VC之外其它编译器如gcc中没 ...