2019CCPC女生专场赛_K - Tetris_打表/模拟_暴力之王

HDU - 6554

题目链接在此!

wls 有一个 n ∗ m 的网格,他现在想用俄罗斯方块中的"凸"型密铺它。一个"凸"型占四个格子,你可以随意把它调成上下左右四个方向中的一个。密铺的定义是网格中任意一个格子被且只被一个"凸"型铺到,并且这些"凸"型不能铺出网格的边界。
随意输出一组解即可。
Input
一行两个整数 n, m。
1 ≤ n, m ≤ 12
Output
无解输出 no response。
如果有解,输出 n 行,每行 m 个字符。你只能使用 1, 2, 3, 4 这四个字符,由同 一字符组成的四连通块被视为一个"凸"型。
如果有多组解,那么输出任意一种即可。
Sample Input
4 4
Sample Output
1113
2133
2243
2444

思路分析:
一定要说的话,还可以叫构造,实际上基础的矩形单位是4X4的方块。
代码:

#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#define INF 0x3f3f3f3f
#define MAX 200100
#define ll long long
#define N 10010
using namespace std;
int n, m;
int ans[14][14];

void init()
{
    ans[0][0] = ans[0][1] = ans[0][2] = ans[1][1] = 1;
    ans[1][0] = ans[2][0] = ans[3][0] = ans[2][1] = 2;
    ans[0][3] = ans[1][3] = ans[2][3] = ans[1][2] = 3;
    ans[3][1] = ans[3][2] = ans[3][3] = ans[2][2] = 4;
}

void print(int i)
{
    for(int j = 0; j < m; j++)
    {
        printf("%d", ans[i][j % 4]);

    }
    printf("\n");
}

int main()
{
    ans[14][14] = {0};
    while(scanf("%d%d", &n, &m) != EOF)
    {
        init();
        if (n % 4 != 0 || m % 4 != 0)
        {
            printf("no response\n\n");
        }
        else
        {
            for(int i = 0; i < n; i++)
            {
                print(i % 4);
            }
            printf("\n");
        }
    }
    return 0;
}

两个\n,我服了!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值