Crossword Answers UVA - 232
题目大意
感觉挺水的一道题。找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题)
解析
①找出各个格子的编号
②对每个节点搜索一下
③输出的时候注意最后一个数据后面没有空行,也就是空行得在上面出
代码
#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的更多相关文章
- 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 ...
- 【习题 3-6 UVA - 232】Crossword Answers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟题.注意场宽为3 [代码] #include <bits/stdc++.h> using namespace std ...
- 紫书第三章训练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 ...
- [刷题]算法竞赛入门经典 3-4/UVa455 3-5/UVa227 3-6/UVa232
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 题目:算法竞赛入门经典 3-4/UVa455:Periodic Strings 代码: //UVa455 #inclu ...
随机推荐
- python安装了2.7之后终端无法使用退格,上下左右
遇到RT问题,原因是由于在编译python的时候去烧readline库造成的 解决办法: yum install readline-devel 然后重新编译安装python,终端控制符可用!
- 中国剩余定理模板&俄罗斯乘法
void ex_gcd(ll a,ll b,ll &d,ll &x,ll &y){ if(!b){d=a;x=1LL;y=0LL;} else {ex_gcd(b,a%b,d, ...
- [RK3288][Android6.0] 调试笔记 --- 录音音量从HAL到APP层会变小问题【转】
本文转载自:http://blog.csdn.net/kris_fei/article/details/72783843?locationNum=9&fps=1 Platform: Rockc ...
- BZOJ_3175_[Tjoi2013]攻击装置_二分图匹配
BZOJ_3175_[Tjoi2013]攻击装置_二分图匹配Description 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照“日”字攻击其周围的 8个位置 ...
- [Codeforces 140C] New Year Snowmen
[题目链接] https://codeforces.com/problemset/problem/140/C [算法] 显然 , 我们每次应优先考虑数量多的雪球 将雪球个数加入堆中 , 每次取出数量前 ...
- Ado.net设计模式
连接类 连接类有固定的使用模式,这是常用的乐观模式: using (var conn = new SqlConnection(connstr)) { conn.Open(); //执行各种数据库操作 ...
- bzoj1036 [ZJOI2008]树的统计Count——LCT
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1036 LCT水题! 然而没有1A(咬牙)! 注意值有负数,所以取 max 的话要把作为“哨兵 ...
- ORACLE获取某个时间段之间的月份列表和日期列表
ORACLE获取某个时间段之间的月份列表获取某个时间段之间的月份列表(示例返回2009-03到2010-03之间的月份列表) SELECT TO_CHAR(ADD_MONTHS(TO_DATE('20 ...
- IJ:工程配置Tomcat
ylbtech-IJ:工程配置Tomcat 1.返回顶部 1. 1.2. 1.3. 1.4. 2. 2.返回顶部 1. 2. 3.返回顶部 1. 2. 4.返回顶部 0.修改文件位置 D:\work- ...
- E20170611-hm
ascending adj. 上升的,向上的; ascend vt. 攀登; 继承; 占领; vi. 上升; 爬坡; 追溯; descending n. 递减; descend v ...