Tetris
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
Source
2019中国大学生程序设计竞赛-女生专场(重现赛)-感谢南京晓庄学院
AC代码
#include"iostream"
#include"string"
using namespace std;
int main()
{
string a[4] ;
a[0] = "1113";
a[1] = "2133";
a[2] = "2243";
a[3] = "2444";
int n,m;
while(cin>>n>>m)
{
if(n%4==0&&m%4==0)
{
for(int j = 0;j<n;j++)
{
for(int i = 0;i<m/4;i++)
{
cout<<a[j%4];
}
cout<<endl;
}
}
else if(n<1||m<1||n>12||m>12)
cout<<"no response"<<endl;
else
cout<<"no response"<<endl;
}
}