Holding Two
Given n, m, construct a matrix A of size n × m, whose entries are all either 0 or 1, and no three distinct entries 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 ≤ 1. If multiple solutions exist, print any one of them. If no solution, print “-1” in one line. Input Input only one line containing two integers n, m (1 ≤ n, m ≤ 1000). Output If solutions exist, print n lines each containing a 01-string of length m, denoting the matrix you construct. If no solution, print “-1” in one line.
Example standard
input
3 3
output
110
001
100
题意就是不能有连续的三个相等的字符
001100110011
110011001100
………………
………………
这样排就满足题意
#include<iostream>
using namespace std;
int main()
{int n,m;cin>>n>>m;string s="";string s1="";int k;for(int i=0;i<m;i++){k=i/2;if(k%2==1)s+='1';elses+='0';}for(int i=0;i<m;i++){k=i/2;if(k%2==1)s1+='0';elses1+='1';}for(int i=1;i<=n;i++){if(i%2==1)cout<<s<<endl;elsecout<<s1<<endl;}
}
Holding Two相关推荐
- another app is currently holding the yum lock;waiting for it to exit解决
有时用yum升级一些文件时,会出现以下情况: another app is currently holding the yum lock;waiting for it to exit... 可以通过强 ...
- centos在yum install报错:Another app is currently holding the yum lock解决方法
centos在yum install报错:Another app is currently holding the yum lock解决方法 参考文章: (1)centos在yum install报错 ...
- c# 连接Redis报错:WRONGTYPE Operation against a key holding the wrong kind of value:类型搞混弄出的错误...
今天用C# 连接Redis做性能测试,用的接口是StackExchange.Redis,按照正常的思路获取数据库连接,代码如下: 1 string conn = "我的ip:6379,pas ...
- Another app is currently holding the yum lock; waitingn
yum配置提示错误: [root@localhost yum.repos.d]# yum clean all Another app is currently holding the yum lock ...
- Centos Another app is currently holding the yum lock
yum命令用ctrl+z命令中断后,再运行yum时,出现: Existing lock /var/run/yum.pid: another copy is running as pid 3046. A ...
- redis.exceptions.ResponseError: WRONGTYPE Operation against a key holding the wrong kind of value
完整报错如下: (Python3.6) appleyuchi@ubuntu19:有序集合$ python example_of_range.py Traceback (most recent cal ...
- 解决Another app is currently holding the yum lock; waiting for it to exit...问题
在下载安装lrzsz时出现Another app is currently holding the yum lock; waiting for it to exit...问题yum被锁定了可以使用 ` ...
- Another app is currently holding the yum lock; waiting for it to exit...
使用yum安装计划任务功能,结果提示: # yum -y install vixie-cron Loaded plugins: fastestmirror, refresh-packagekit, s ...
- yum提示Another app is currently holding the yum lock; waiting for it to exit...
使用yum安装计划任务功能,结果提示: # yum update Loaded plugins: fastestmirror, refresh-packagekit, security Existin ...
- 解决yum锁定Another app is currently holding the yum lock; waiting for it to exit...
完整的报警如下: Another app is currently holding the yum lock; waiting for it to exit...The other applicati ...
最新文章
- usaco Home on the Range
- 收藏 | 深度学习损失函数大全(附代码实现)
- 11月下旬国内域名解析商Top10:中国数据5.03%居第四
- comboBox.DataSource绑定
- arduino 舵机接线图_求用5个电位器分别控制舵机的arduino的原码和连线图
- JS最新的身份证验证代码
- 微软亚洲研究院NLC组招聘实习生!与一线研究员共探NLP前沿与落地!
- NYOJ-苹果(dp)
- File类与FileInfo类
- 掌握 cinder-scheduler 调度逻辑 - 每天5分钟玩转 OpenStack(48)
- 阿里云ECS建网站(建站)超详细全套完整图文教程!菜鸟必看!
- POS打印机设置字体大小
- 使用jQuery填充tbody时,填充了两倍数据
- Activiti工作流会签设计
- 《商用密码应用与安全性评估》第四章 密码应用安全性评估实施要点-小结
- 磁盘必须经过初始化,逻辑磁盘管理器才能访问——笔记本硬盘作为移动硬盘使用时遇到的问题...
- EXCEL中发现不可读的内容。是否恢复此工作薄的内容?如果信任此工作薄的来源,请单击”是“
- 不能装载文档控件。请在检查浏览器的选项中检查浏览器的安全设置_【网络安全宣传周】网络安全小黑板 | 如何正确设置浏览器...
- 7.4 FIN及其ACK的接收
- csp2015-03
热门文章
- [Eigen]Eigen的单位矩阵C++
- 花椒六间房“花房之夜”落幕 全新升级不止心动
- Android 集成facebook 登录和分享
- 最新最佳最重要的计算机相关网站推荐(更新版)
- 《网络是这样连接的》读书笔记2
- 实用系列1 —— 视频中的语音转换成文字
- UEFI edk2>edksetup.bat --nt32,build,无法解析的符号解决办法
- excel查找出不来了_Excel技巧:明明看到1了,为什么查找不到?
- 【已解决】Mysql 存储 emoji 表情报错 Incorrect string value: ‘\xF0\x9F\x98\x82\xF0\x9F
- 崔希凡JavaWeb笔记day19-day21(2016年10月4日17:35:51)