链接:https://ac.nowcoder.com/acm/contest/11256/H〰 来源:牛客网
时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524288K Special Judge, 64bit IO Format: %lld
题目描述
Given n,mn,m_{}n,m, construct a matrix AA_{}A of size n×mn\times mn×m, whose entries are all either 0 or 1, and no three distinct entries Ai1,j1,Ai2,j2,Ai3,j3A_{i_1,j_1}, A_{i_2,j_2}, A_{i_3,j_3}Ai1,j1,Ai2,j2,Ai3,j3 satisfying that Ai1,j1=Ai2,j2=Ai3,j3,−1≤i1−i2=i2−i3≤1,−1≤j1−j2=j2−j3≤1A_{i_1,j_1} = A_{i_2,j_2} = A_{i_3,j_3}, -1\le i_1-i_2=i_2-i_3\le 1, -1\le j_1-j_2=j_2-j_3\le 1Ai1,j1=Ai2,j2=Ai3,j3,−1≤i1−i2=i2−i3≤1,−1≤j1−j2=j2−j3≤1. If multiple solutions exist, print any one of them. If no solution, print “-1” in one line.
输入描述:
Input only one line containing two integers n,m (1≤n,m≤1000)n, m~(1\le n,m \le 1000)n,m (1≤n,m≤1000).
输出描述:
If solutions exist, print nn_{}n lines each containing a 0101_{}01-string of length mm_{}m, denoting the matrix you construct. If no solution, print "-1" in one line.
示例1
输入
3 3
输出
110
001
100
解释与代码
我们可以构造出 0011 1100 这样重复的数字即可
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <limits.h>
#include <assert.h>
#include <functional>
#include <numeric>
#include <ctime>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define ppb pop_back
#define lbnd lower_bound
#define ubnd upper_bound
#define endl '\n'
#define mll map<ll,ll>
#define msl map<string,ll>
#define mls map<ll, string>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define trav(a, x) for(auto& a : x)
#define pll pair<ll,ll>
#define vl vector<ll>
#define vll vector<pair<ll, ll>>
#define vs vector<string>
#define all(a) (a).begin(),(a).end()
#define F first
#define S second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define DEBUG cerr<<"/n>>>I'm Here<<</n"<<endl;
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl;
#define what_is(x) cerr << #x << " is " << x << endl;
#define ini(a) memset(a,0,sizeof(a))
#define ini2(a,b) memset(a,b,sizeof(a))
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define sc ll T;cin>>T;for(ll Q=1;Q<=T;Q++)
#define lowbit(x) x&(-x)
#define pr printf
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DBG(x) \
(void)(cout << "L" << __LINE__ \
<< ": " << #x << " = " << (x) << '\n')
#define TIE \
cin.tie(0);cout.tie(0);\
ios::sync_with_stdio(false);
//#define long long int
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 200009;
const ll N = 1000000007;
const ull N2 = 1000000007;
int cb[][10] = {{1,1,0,0},
{0,0,1,1}};
void solve(){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cout<<cb[i%2][j%4];
}
cout<<endl;
}
}
int main()
{
// TIE;
// #ifndef ONLINE_JUDGE
// freopen ("input.txt","r",stdin);
// #else
// #endif
solve();
// sc{solve();}
// sc{cout<<"Case "<<Q<<":"<<endl;solve();}
}