【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

模拟题。注意场宽为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的更多相关文章

  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. Crossword Answers UVA - 232

    题目大意 感觉挺水的一道题.找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题) 解析 ①找出各个格子的编号 ②对每个节点搜索一下 ③输出的时候注意最后一个数据后面 ...

  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. ACM训练计划建议(写给本校acmer,欢迎围观和指正)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

随机推荐

  1. Kinect 开发 —— 控制PPT播放

    实现Kinect控制幻灯片播放很简单,主要思路是:使用Kinect捕捉人体动作,然后根据识别出来的动作向系统发出点击向前,向后按键的事件,从而使得幻灯片能够切换. 这里的核心功能在于手势的识别,我们在 ...

  2. host---域名查询

    host命令是常用的分析域名查询工具,可以用来测试域名系统工作是否正常. 选项 -a:显示详细的DNS信息: -c<类型>:指定查询类型,默认值为“IN“: -C:查询指定主机的完整的SO ...

  3. ubuntu 进入临时客户会话页面 转入用户自己页面

    1.点击右上角的按钮 2.选择要登录的客户名字 点击进入 3.输入账号密码 进入指定的账号

  4. dp水题

    hdu 2084: #include <stdio.h> #include <iostream> #include <string.h> using namespa ...

  5. 【Codeforces Round #457 (Div. 2) B】Jamie and Binary Sequence

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 把n分解成二进制的形式. n=2^a0+2^a1+...+2^a[q-1] 则固定就是长度为q的序列. 要想扩展为长为k的序列. 可 ...

  6. POJ 4047 Garden

    Garden Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 404 ...

  7. 平衡数之Treap

    #include <memory>//智能指针头文件 #include <random>//随机数头文件 #include <iostream> #include ...

  8. jquery constructor(null)

    <!-- jQuery = function() { --> <!-- return new jQuery.fn.F(); --> <!-- }, --> < ...

  9. 1.25 Python知识进阶 - 封装

    封装 示例代码: class Role(object): count = 0 def __init__(self,name,role,weapon,life_value=100,money=15000 ...

  10. RecyclerView 展示多种类型Item数据

    一.多Item布局实现(MultipleItem) 如果之前你用过ListView实现过此功能,那么你一定对下面这两个方法并不陌生 @Override public int getItemViewTy ...