当前位置:网站首页>C. colonne Swapping [tri + Simulation]
C. colonne Swapping [tri + Simulation]
2022-07-07 05:55:00 【Rétrospective du roi dragon blanc】
Analyse
Notez où chaque ligne ne correspond pas au tri
Si plus de trois refroidissements directs
Et avec unsetLes dossiers doivent être changés(l,r)
Si plus de1Cool.
Et puis on juge chaque lignel rDoit satisfairea[l] < a[r]
Sinon, il fait froid
ac code
import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m = list(map(int, input().split()))
grid = [[0] * m for _ in range(n)]
for i in range(n):
grid[i] = list(map(int, input().split()))
flag = True
mustChanges = set()
for i in range(n):
lst = []
temp = sorted(grid[i])
for j in range(m):
if temp[j] != grid[i][j]:
lst.append(j)
if len(lst) > 2:
flag = False
break
elif len(lst) == 2:
mustChanges.add((lst[0], lst[1]))
if len(mustChanges) >= 2:
flag = False
break
if not flag:
print(-1)
else:
if len(mustChanges) == 0:
print(1, 1)
else:
l, r = list(mustChanges)[0]
flag = True
for i in range(n):
if grid[i][l] < grid[i][r]:
flag = False
break
if flag:
print(l + 1, r + 1)
else:
print(-1)
Résumé
Trier + Simulation
边栏推荐
- Realize GDB remote debugging function between different network segments
- 一个简单的代数问题的求解
- AI人脸编辑让Lena微笑
- Question 102: sequence traversal of binary tree
- TCC of distributed transaction solutions
- 关于服装ERP,你知道多少?
- Polynomial locus of order 5
- Loss function and positive and negative sample allocation in target detection: retinanet and focal loss
- Digital IC interview summary (interview experience sharing of large manufacturers)
- What is message queuing?
猜你喜欢
Interview skills of software testing
What is dependency injection (DI)
AI face editor makes Lena smile
Forkjoin is the most comprehensive and detailed explanation (from principle design to use diagram)
往图片添加椒盐噪声或高斯噪声
Nvisual network visualization
目标检测中的BBox 回归损失函数-L2,smooth L1,IoU,GIoU,DIoU,CIoU,Focal-EIoU,Alpha-IoU,SIoU
Message queuing: how to ensure that messages are not lost
Hcip seventh operation
每秒10W次分词搜索,产品经理又提了一个需求!!!(收藏)
随机推荐
Things about data storage 2
谈fpga和asic的区别
软件测试面试技巧
上海字节面试问题及薪资福利
The 2022 China low / no code Market Research and model selection evaluation report was released
Nvisual network visualization
980. 不同路径 III DFS
力扣102题:二叉树的层序遍历
【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
How to get free traffic in pinduoduo new store and what links need to be optimized in order to effectively improve the free traffic in the store
拼多多新店如何获取免费流量,需要从哪些环节去优化,才能有效提升店内免费流量
毕业之后才知道的——知网查重原理以及降重举例
话说SQLyog欺骗了我!
常用消息队列有哪些?
zabbix_get测试数据库失败
win配置pm2开机自启node项目
SAP ABAP BDC(批量数据通信)-018
PTA 天梯赛练习题集 L2-002 链表去重
Input of native applet switches between text and password types
关于服装ERP,你知道多少?