题目大意

感觉挺水的一道题。找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题)

解析

①找出各个格子的编号

②对每个节点搜索一下

③输出的时候注意最后一个数据后面没有空行,也就是空行得在上面出

代码

#include <bits/stdc++.h>
using namespace std;
char mp[100][100];
int bk[100][100],bk1[100][100],bk2[100][100];
int n,m;
void dfs(int x,int y)
{
printf("%3d.",bk[x][y]);
while(1)
{
if(mp[x][y]!='*'&&y<m)
{
cout<<mp[x][y];
y++;
bk1[x][y]=1;
}
else
{
cout<<endl;
break;
}
}
}
void dfs1(int x,int y)
{
printf("%3d.",bk[x][y]);
while(1)
{
if(mp[x][y]!='*'&&x<n)
{
cout<<mp[x][y];
x++;
bk2[x][y]=1;
}
else
{
cout<<endl;
break;
}
}
}
int main()
{
/*ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
int t=1;
while(cin>>n>>m)
{
if(n==0)
break;
int p=0;
memset(bk,0,sizeof(bk));
memset(bk1,0,sizeof(bk1));
memset(bk2,0,sizeof(bk2));
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
cin>>mp[i][j];
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(i-1<0||j-1<0||mp[i-1][j]=='*'||mp[i][j-1]=='*')
if(mp[i][j]!='*')
bk[i][j]=++p;
if(t>1)
cout<<"\n";
printf("puzzle #%d:\n",t++);
printf("Across\n");
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(!bk1[i][j]&&mp[i][j]!='*')
dfs(i,j);
printf("Down\n");
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
if(!bk2[i][j]&&mp[i][j]!='*')
dfs1(i,j);
//cout<<"\n";
}
}

Crossword Answers UVA - 232的更多相关文章

  1. UVa 232 Crossword Answers

     Crossword Answers  A crossword puzzle consists of a rectangular grid of black and white squares and ...

  2. UVa232.Crossword Answers

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  3. Uva 232 一个换行WA 了四次

    由于UVA OJ上没有Wrong anwser,搞的多花了好长时间去测试程序,之前一直以为改OJ有WA,后来网上一搜才知道没有WA,哎哎浪费了好长时间.此博客用来记录自己的粗心大意. 链接地址:htt ...

  4. poj 1888 Crossword Answers 模拟题

    Crossword Answers Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 869   Accepted: 405 D ...

  5. 【习题 3-6 UVA - 232】Crossword Answers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题.注意场宽为3 [代码] #include <bits/stdc++.h> using namespace std ...

  6. 紫书第三章训练1 D - Crossword Answers

    A crossword puzzle consists of a rectangular grid of black and white squares and two lists of defini ...

  7. UVA 232 Corssword Answer

    题意:输入m*n大小的字符串(里面有*,*为黑格,其他为白格),然后对它编号,编号规则为从左到右,从上往下,且左边或上面没有白格(可能是黑格或越界),如下图: 注意: ①除第一次输出答案外,其余每次输 ...

  8. Crossword Answers -------行与列按序输出

    题目链接:https://vjudge.net/problem/UVA-232#author=0 题意:关键句:The de nitions correspond to the rectangular ...

  9. [刷题]算法竞赛入门经典 3-4/UVa455 3-5/UVa227 3-6/UVa232

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 题目:算法竞赛入门经典 3-4/UVa455:Periodic Strings 代码: //UVa455 #inclu ...

随机推荐

  1. 第一次PHP面试题

    1.标记符title是放在标记符什么之间:head 2.级联样式表文件的扩展名:CSS 3.html中<pre>的作用:pre 元素可定义预格式化的文本 4.mysql_affected_ ...

  2. YTU 2635: P4 游戏中的Human角色

    2635: P4 游戏中的Human角色 时间限制: 1 Sec  内存限制: 128 MB 提交: 524  解决: 328 题目描述 在一个平面打斗游戏中,任何的角色(Role)都有血量(bloo ...

  3. phpstorm配置php脚本执行

    1.到设置中配置 2.配置具体项 3.完了就可以执行php脚本了

  4. js鼠标事情

    js鼠标事情 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset=" ...

  5. [Codeforces 1058E] Vasya and Good Sequences

    [题目链接] https://codeforces.com/contest/1058/problem/E [算法] 显然 , 我们只需考虑序列中每个数的二进制表示下1的个数即可. 不妨令Ai表示第i个 ...

  6. 【POJ 2983】 Is the information reliable?

    [题目链接] 点击打开链接 [算法] 差分约束系统,SPFA判负环 [代码] #include <algorithm> #include <bitset> #include & ...

  7. 21 WPF数据视图

    视图对象 当你绑定集合到ItemsControl,在幕后数据视图被安静地创造.视图位于数据源和绑定控件之间.数据视图是通往数据源的一个窗口.它跟踪当前项目,它支持诸如排序,过滤,和分组特征.这些特征独 ...

  8. gitlab邮箱验证 邮箱提醒设置

    Gitlab邮件提醒方便跟踪项目进度,在这里介绍两种方式,一种是用系统的sendmail发送邮件,另一种是GMAIL的stmp来发送邮件   第一种 用系统的sendmail发送邮件   cd /ho ...

  9. Java序列化系列教程(下)

    一引言 将 Java 对象序列化为二进制文件的 Java 序列化技术是 Java 系列技术中一个较为重要的技术点,在大部分情况下,开发人员只需要了解被序列化的类需要实现 Serializable 接口 ...

  10. 题解报告:poj 3468 A Simple Problem with Integers(线段树区间修改+lazy懒标记or树状数组)

    Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. On ...