Kakuro Extension Extension

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 507    Accepted Submission(s): 248

Problem Description
You know ,I'm a lazy guy and write problem description is a very very boring thing.So , I would not repeat the rule of Kakuro again , Please look at this.But things are different again,contray to the problem above,this time you should work out the input file according to the output file.
 
Input
The first line of the inputs is T, which stands for the number of test cases you need to solve.
Then T case follow:
Each test case starts with a line contains two numbers N,M (2<=N,M<=100)and then N lines follow, each line contains M columns, either ‘_’ or 1~9. You can assume that the first column of the first line is ’_’.
 
Output
Output N lines, each line contains M parts, each part contains 7 letters. The m parts are seperated by spaces.Output a blank line after each case.
 
Sample Input
2 6 6 _ _ _ _ _ _ _ _ 5 8 9 _ _ 7 6 9 8 4 _ 6 8 _ 7 6 _ 9 2 7 4 _ _ _ 7 9 _ _ 5 8 _ _ _ _ _ _ _ _ _ 1 9 9 1 1 8 6 _ _ 1 7 7 9 1 9 _ 1 3 9 9 9 3 9 _ 6 7 2 4 9 2 _
 
Sample Output
XXXXXXX XXXXXXX 028\XXX 017\XXX 028\XXX XXXXXXX XXXXXXX 022\022 ....... ....... ....... 010\XXX XXX\034 ....... ....... ....... ....... ....... XXX\014 ....... ....... 016\013 ....... ....... XXX\022 ....... ....... ....... ....... XXXXXXX XXXXXXX XXX\016 ....... ....... XXXXXXX XXXXXXX XXXXXXX 001\XXX 020\XXX 027\XXX 021\XXX 028\XXX 014\XXX 024\XXX XXX\035 ....... ....... ....... ....... ....... ....... ....... XXXXXXX 007\034 ....... ....... ....... ....... ....... ....... XXX\043 ....... ....... ....... ....... ....... ....... ....... XXX\030 ....... ....... ....... ....... ....... ....... XXXXXXX
 
Author
shǎ崽
 
Source
 
Recommend
 
 
 
 
 

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[105][105];

void pd(int x,int y,int m,int n)
{
    if(a[x][y]>='1'&&a[x][y]<='9')
    {
        printf(".......");
        return ;
    }
    int sum1=0,sum2=0;
    int flag1=0;
    int flag2=0;
    if(x==m)
        flag1=1;
    if(y==n)
        flag2=1;
    for(int i=x+1; i<=m; i++)
    {
        if(a[x+1][y]=='_')
            flag1=1;
        if(a[i][y]=='_')
            break;
        sum1=sum1+(a[i][y]-'0');
    }
    for(int j=y+1; j<=n; j++)
    {
        if(a[x][y+1]=='_')
            flag2=1;
        if(a[x][j]=='_')
            break;
        sum2=sum2+(a[x][j]-'0');
    }
    if(flag1==1&&flag2==1)
    {
        printf("XXXXXXX");

}
    else if(flag1==1&&flag2==0)
    {
            printf("XXX");
            printf("\\");
            printf("%03d",sum2);

}
    else if(flag1==0&&flag2==1)
    {
            printf("%03d",sum1);
            printf("\\");
            printf("XXX");
    }
    else if(flag1==0&&flag2==0)
    {
            printf("%03d\\%03d",sum1,sum2);
    }

}
int main()
{
    int m,n;
    int t;
    scanf("%d",&t);
    while(t--)
    {
        memset(a,0,sizeof(a));
        scanf("%d%d",&m,&n);
        getchar();
        for(int i=1; i<=m; i++)
        {
            for(int j=1; j<=n; j++)
            {
                //scanf("%c",&a[i][j]);
                cin >> a[i][j];
            }

}
        char ch=' ';
        for(int i=1; i<=m; i++)
        {
            for(int j=1; j<=n; j++)
            {
                /*if(a[1][1]!='_')
                    a[1][1]='_';*/
                pd(i,j,m,n);
                if(j!=n)
                    printf("%c",ch);
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

HDU3344(小广搜+小暴力的更多相关文章

  1. P3818 小A和uim之大逃离 II(bfs,有条件的广搜)

    题目背景 话说上回……还是参见 https://www.luogu.org/problem/show?pid=1373 吧 小a和uim再次来到雨林中探险.突然一阵南风吹来,一片乌云从南部天边急涌过来 ...

  2. hdu 1195:Open the Lock(暴力BFS广搜)

    Open the Lock Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  3. 大三上学期安卓一边学一边开始做一个自己觉得可以的项目 广商小助手App 加油

    这项目构思好多 一个人一步一步来 一边做一边为后面应用铺设 广商小助手APP 设计出的软件登录场景 实现(算是可以) 界面大体出来了 界面点击方面也做了很多特效 上图其实点击各颜色后会出现各种图和反应 ...

  4. HDU--杭电--1195--Open the Lock--深搜--都用双向广搜,弱爆了,看题了没?语文没过关吧?暴力深搜难道我会害羞?

    这个题我看了,都是推荐的神马双向广搜,难道这个深搜你们都木有发现?还是特意留个机会给我装逼? Open the Lock Time Limit: 2000/1000 MS (Java/Others)  ...

  5. 双向广搜+hash+康托展开 codevs 1225 八数码难题

    codevs 1225 八数码难题  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond   题目描述 Description Yours和zero在研究A*启 ...

  6. hdu 1242:Rescue(BFS广搜 + 优先队列)

    Rescue Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submis ...

  7. 深搜(DFS)广搜(BFS)详解

    图的深搜与广搜 一.介绍: p { margin-bottom: 0.25cm; direction: ltr; line-height: 120%; text-align: justify; orp ...

  8. P1256 显示图像(广搜)

    题意:略 思路,先说如何建树吧.广搜很简单,就是一个队列+一个检测数组.但是本质还是对搜索树的构建. 这里的构建就是一个节点有4个孩子,每个孩子代表4个方向就构成了一个搜索树.根据题目的就离公式转化一 ...

  9. 解救小哈——bfs广搜

    问题描述: 小哈去玩迷宫,结果迷路了,小哼去救小哈.迷宫由n行m列的单元格组成(n和m都小于等于50),每个单元格要么是空地,要么是障碍物. 问题:帮小哼找到一条从迷宫的起点通往小哈所在位置的最短路径 ...

随机推荐

  1. WCF 入门(20)

    前言 Happy weekend. 第20集 通过实现IErrorHandler接口来统一处理WCF里的异常 Centralized exception handling in WCF by impl ...

  2. Graphics samples2

    为图形填充渐变色: Graphics2D g2=(Graphics2D)g; GradientPaint gra=new GradientPaint(20, 20, Color.BLUE, 100,8 ...

  3. android 通过帧动画方式播放Gif动画

    注意:经过本人测试,这个方法很耗内存, 图片一多就崩了.慎用 <1>用工具(photoshop或者FireWorks)将GIF动画图片分解成多个GIF静态图片,然后保存在res\drawa ...

  4. beta版本贡献率

    队名:攻城小分队 031302410 郭怡锋 : 占比:50% 031302411 洪大钊: 占比:30% 031302206 陈振贵: 占比:10% 031302416 黄伟祥: 占比:10%

  5. CentOS7 安装 Mono

    官网参考:http://www.mono-project.com/docs/getting-started/install/linux/#centos-7-fedora-19-and-later-an ...

  6. Spring控制Hibernate的缓存机制ehcache

    首先在spring.xml中进入bean <prop key="hibernate.cache.use_second_level_cache">true</pro ...

  7. Tomcat server.xml详解

    Server.xml的结构大致 <Server port="8005" shutdown="SHUTDOWN"> <Service name= ...

  8. ztree设置节点checked

    1.根据id获取树的某个节点: var zTree = $.fn.zTree.getZTreeObj("mytree"); var node = zTree.getNodeByPa ...

  9. 最短路算法floyd

    内容: 对n个点(n<=450),已知他们的边,也就是相邻关系,求任意两个点的最短距离. 代码: for(int k=1; k<=n; k++)//k写在外面 for(int i=1; i ...

  10. Informatica 错误:Cannot convert from SQL type 93 to C type 4

    经验和积累蛮重要!向大神学习! ---------------------------------------------------------------------- Mapping: 在sou ...