当前位置:网站首页>cf:B. Almost Ternary Matrix【對稱 + 找規律 + 構造 + 我是構造垃圾】
cf:B. Almost Ternary Matrix【對稱 + 找規律 + 構造 + 我是構造垃圾】
2022-07-05 18:58:00 【白速龍王的回眸】
分析
趨於對稱,由於是2的倍數,所以考慮基本單元2 * 2
1 0 | 0 1
0 1 | 1 0
ABA…
BAB…
…
我們如上定義兩種特殊的2 * 2的A和B
然後就可以構造出來AB交錯的樣子,符合第一第二個實例
ac code
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m = list(map(int, input().split()))
# 1 0 | 0 1
# 0 1 | 1 0
# ABA...
# BAB...
# ...
even = [1, 0, 0, 1]
odd = [0, 1, 1, 0]
ans = [[0] * m for _ in range(n)]
for i in range(n):
for j in range(m):
if i % 4 == 0 or i % 4 == 3:
ans[i][j] = even[j % 4]
else:
ans[i][j] = odd[j % 4]
for row in ans:
print(*row)
總結
我是構造垃圾
我是找規律小垃圾
边栏推荐
- The easycvr authorization expiration page cannot be logged in. How to solve it?
- Take a look at semaphore, the current limiting tool provided by JUC
- 技术分享 | 常见接口协议解析
- How much does the mlperf list weigh when AI is named?
- 进程间通信(IPC):共享内存
- The road of enterprise digital transformation starts from here
- Oracle date format conversion to_ date,to_ char,to_ Timestamp mutual conversion
- Linear table - abstract data type
- [detailed explanation of AUTOSAR 14 startup process]
- Various pits of vs2017 QT
猜你喜欢
如何快速进阶自动化测试?听听这3位BAT大厂测试工程师的切身感想....
Icml2022 | partial and asymmetric comparative learning of out of distribution detection in long tail recognition
RedHat7.4配置yum软件仓库(RHEL7.4)
国内低代码开发平台靠谱的都有哪些?
Overview of video self supervised learning
Postman核心功能解析 —— 参数化和测试报告
Case sharing | integrated construction of data operation and maintenance in the financial industry
企业数字化转型之路,从这里开始
Web3.0时代来了,看天翼云存储资源盘活系统如何赋能新基建(下)
FCN: Fully Convolutional Networks for Semantic Segmentation
随机推荐
[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD
如何快速进阶自动化测试?听听这3位BAT大厂测试工程师的切身感想....
解决 contents have differences only in line separators
ROS安装报错 sudo: rosdep:找不到命令
Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v
Oracle 中文排序 Oracle 中文字段排序
vs2017 qt的各种坑
Low code practice of xtransfer, a cross-border payment platform: how to integrate with other medium-sized platforms is the core
2022 latest Android interview written examination, an Android programmer's interview experience
UDF implementation of Dameng database
lombok @Builder注解
Taishan Office Technology Lecture: from the layout height of the line, talk about the height overflow and height shrinkage of the drawing height (launched in the whole network)
【历史上的今天】7 月 5 日:Google 之母出生;同一天诞生的两位图灵奖先驱
websocket 工具的使用
2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]
Linear table - abstract data type
RPC协议详解
一朵云开启智慧交通新未来
MySQL数据库索引教程(超详细)
2022最新Android面试笔试,一个安卓程序员的面试心得