【习题 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 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
随机推荐
- vim 基础学习之可视模式
1. 选择模式这个模式必须通过可视模式进入.在可视模式下,我们通过 <C-g>来把我们的可视选中块作为选择模式下的操作块. 这时候我们输入可见字符,就会把这个块给覆盖掉.例如aaa bbb ...
- 用C#调用Lua脚本
用C#调用Lua脚本 一.引言 学习Redis也有一段时间了,感触还是颇多的,但是自己很清楚,路还很长,还要继续.上一篇文章简要的介绍了如何在Linux环境下安装Lua,并介绍了在Linux环境下如何 ...
- element-ui一些注意点:
1.change ($event,“你要传递的其他值”),使用el-select组件时,想传递多个值. 或者 在el-option上的value属性上传递对象 eg: :value="{'c ...
- VS Code 关于SFTP上传文件到多服务器的配置
工欲善其事,必先利其器! 刚学前端的时候一直用的DW来编写代码,其功能非常强大,但在Linux下不能用,所以就转VS Code了. 但是刚开始使用VS Code的时候,很多DW上的功能需要自己安装扩展 ...
- Model、ModelMap、ModelAndView的作用及区别
Model.ModelMap.ModelAndView的作用及区别 对于MVC框架,控制器controller执行业务逻辑 用于产生模型数据Model 视图view用来渲染模型数据 Model和Mod ...
- iOS报错 -pie can only be used when targeting iOS 4.2 or later
近期,使用师兄的project时.突然报错之前没发现这个错误.信息例如以下: ld: -pie can only be used when targeting iOS 4.2 or later cla ...
- [TypeScript] Shallow copy object by using spread opreator
For example we have an object: const todo = { text: "Water the flowers", completed: false, ...
- [51Nod]NOIP2018提高组省一冲奖班模测训练(一)题解
http://www.51nod.com/contest/problemList.html#!contestId=72&randomCode=147206 原题水题大赛.. A.珂朵莉的旅行 ...
- Spring中JDBCTemplate的入门
Spring是IOC和AOP的容器框架,一站式的框架 连接数据库的步骤:[必须会写] Spring当中如何配置连接数据库? 第一步配置核心配置文件: <?xml version="1. ...
- Bitmap Image Graphics
Bitmap Image Graphics private void DrawImagePointF(PaintEventArgs e){ // Create image. Image new ...