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 ...
随机推荐
- 从EJB规范理解微服务
晚上看了一篇从JavaEE谈微服务的文章,里面不少观点还是很有启发的,下面最有感触的,从失败的EJB谈微服务. 说起JavaEE规范,要先从EJB(Enterprise Java Bean),他是一种 ...
- 插入CSS的方法
传送门 选择器 selector {declaration1; declaration2; ... declarationN } 例: p { text-aligh:center; } ...
- bzoj 1050: [HAOI2006]旅行comf【枚举+并查集】
m是5000,就想到了直接枚举比例 具体做法是是先把边按照边权从小到大排序,然后先枚举最小边权,再枚举最大边权,就是从最小边权里一个一个加进并查集里,每次查st是否联通,联通则退出,更新答案 #inc ...
- [App Store Connect帮助]六、测试 Beta 版本(3.1)管理测试员:添加内部测试员
您可以添加至多 25 个内部测试员(您的 App Store Connect 用户)使用“TestFlight Beta 版测试”来测试您的 App.在您上传了至少一个构建版本之后,才可添加测试员. ...
- $CF55D [数位DP]$
题面 数位DP+状压. 首先,按照数位DP的基本套路,每个个位数的最小公倍数为2520,所以只用考虑模2520的情况.考虑一个DP.dp[i][j][k]表示当前是第i位,2~9的数的集合为j,模25 ...
- 前端javascript 错误 Uncaught SyntaxError: Unexpected token ILLEGAL
前端控制台报Uncaught SyntaxError: Unexpected token ILLEGAL 错误时,就是非法字符错误,首先检查符号是否正确,不要出现中文标点! 然后检查参数之类的类型是否 ...
- FTP文件服务器
import java.io.InputStream; import java.io.Serializable; import lombok.Data; @Data public class FtpB ...
- 题解报告:hdu 3501 Calculation 2 (欧拉函数的扩展)
Description Given a positive integer N, your task is to calculate the sum of the positive integers l ...
- 最简单的SPA(单页应用)实现
$(function(){ var replacePage = function(href, onFinish){ $.get(href,{},function(raw){ var data = ra ...
- poj2240 Arbitrage
思路: 有向图判负环. 实现: (1)spfa #include <iostream> #include <map> #include <string> #incl ...