当前位置:网站首页>Codeforces Round #804 B Almost Ternary Matrix
Codeforces Round #804 B Almost Ternary Matrix
2022-07-15 19:32:00 【追烽】
https://codeforces.com/contest/1699/problem/B
标签
构造
题意
给定偶数 n 和 m, 找到一个 n 行 m 列的 01 矩阵, 使得矩阵里的每个元素有且仅有 2 个不同的(4 个方向上的)相临元素.
思路
找规律

代码

#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
int a[100][100];
signed main(){
//cin.tie(0)->sync_with_stdio(0);
int T;cin>>T;
while(T--){
int n,m;cin>>n>>m;
memset(a,0,sizeof a);
a[1][1]=1;//a[1][2]=a[2][1]=0;
FOR(j,3,m){
if(a[1][j-2]!=a[1][j-1]) a[1][j]=a[1][j-1];
else a[1][j]=a[1][j-1]^1;
}
FOR(j,1,m) a[2][j]=a[1][j]^1;
FOR(j,1,m){
FOR(i,3,n){
if(a[i-2][j]!=a[i-1][j]) a[i][j]=a[i-1][j];
else a[i][j]=a[i-1][j]^1;
}
}
FOR(i,1,n){
FOR(j,1,m) cout<<a[i][j]<<" ";
cout<<endl;
}
}
return 0;
}
边栏推荐
- 易基因|ENCODE组蛋白ChIP-seq和转录因子ChIP-seq数据标准及处理流程
- apache配置
- 5个时间序列预测的深度学习模型对比总结:从模拟统计模型到可以预训练的无监督模型
- Sqlyog will be stuck if it is not operated for a period of time (solution)
- kingbaseES V8R6集群备份恢复案例之---备库作为repo主机执行物理备份
- 迪赛智慧数——折(渐变堆叠图):全国居民人均可支配收入
- Without training code, the reasoning performance is improved by 1.4 ~ 7.1 times, and the industry's first automatic model compression tool is open source
- go语法-延迟调用defer
- 【源码】tensorboard将MNIST识别训练过程可视化
- Ubuntu 22.04 LTS 是目前最安全的版本的七大原因
猜你喜欢

QT make color selection control

5个时间序列预测的深度学习模型对比总结:从模拟统计模型到可以预训练的无监督模型
Win10定时运行程序

Seven reasons why Ubuntu 22.04 LTS is the safest version at present

设计稳定的微服务系统时不得不考虑的场景

SQL也能玩转AI ?没错!MLOps Meetup V3 回顾|OpenMLBD+SQLFlow+Byzer

【C语言初阶】函数学习报告

Analysis of the new steam curriculum combined with labor education

Cloud document management software docuware cloud how to solve five it problems

论软件自动化测试中 QR_Code 的登录的逻辑
随机推荐
下班前几分钟,我彻底弄懂了JSON.stringify()
网络可信身份认证
Ubuntu 22.04 LTS 是目前最安全的版本的七大原因
网络空间资产探测关键技术研究
论软件自动化测试中 QR_Code 的登录的逻辑
Comprehensive explanation of e-commerce crawler API
小目标检测2_OHEM
[mt2126] Digital Games
Sqlyog will be stuck if it is not operated for a period of time (solution)
User login and registration function with verification code
Google Earth engine app (GEE) - view every image of Amazon plain from 1984 to now
Creativity of project-based learning in children's programming
SQL使用(一):如何使用SQL语句去查询第二高的值
SQL也能玩转AI ?没错!MLOps Meetup V3 回顾|OpenMLBD+SQLFlow+Byzer
推荐系统究竟是什么?
DMS如何赋权数据库函数权限呢?
怎么解决系统高并发问题的思路?看完你就彻底懂了。
易基因|ENCODE组蛋白ChIP-seq和转录因子ChIP-seq数据标准及处理流程
Poll of character device
日志服务器的配置