2019年ccpc女生赛重现赛题解K
Tetris
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
Special Judge
Problem Description
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
思路:蛮傻的一个签到题,n和m只有都是4的倍数的时候才能有解,如果有解的话就把题目给的那个4*4矩阵多输出几个就行了。hdoj上的这题是当多组数据处理的,单组会wa。
#include<bits/stdc++.h>
#define INF 0x3F3F3F3F
#define endl '\n'
#define css(n) cout<<setiosflags(ios::fixed)<<setprecision(n);
#define sd(a) scanf("%d",&a)
#define sld(a) scanf("%lld",&a)
#define m(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n,m;
int t;
double a,b;
string s1,s2,s3,s4;
int main()
{
s1="1113";
s2="2133";
s3="2243";
s4="2444";
while(scanf("%d%d",&n,&m)!=EOF)
{
if(n%4!=0||m%4!=0)
{
cout<<"no response"<<endl;
continue;
}
n=n/4;
m=m/4;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cout<<s1;
}
cout<<endl;
for(int j=1;j<=m;j++)
{
cout<<s2;
}
cout<<endl;
for(int j=1;j<=m;j++)
{
cout<<s3;
}
cout<<endl;
for(int j=1;j<=m;j++)
{
cout<<s4;
}
cout<<endl;
}
}
return 0;
}