编程介的小学生 2019-08-20 21:58 采纳率: 20.5%
浏览 216

交换问题 swap 怎么写

Problem Description
There's a matrix of n rows and m columns whose elements are either 0 or 1.
If an element is 0, it is located at the i-th row and j-th column, there is at least one 1 is located at the i-th row and k-th (k < j) column, and at least one 1 is located at the i-th row and r-th(r > j) column, this element is called Cup.
You can swap any two rows and any two columns of the matrix. You can do this infinite times, to minimize the number of Cups.

Input
Multiple test cases (no more than 50), ended with EOF.
The 1st line of each test case contains two integers n and m (3 ≤ n ≤ 10, 3 ≤ m ≤ 25), the number of rows and the number of columns of the matrix.
Then following n lines, each line has m space-separated 0 or 1, indicating the original configuration of the matrix.

Output
For each test case output a number in one line, indicating the number of minimum Cups can be obtained after the swapping operations.

Sample Input
3 3
1 1 0
1 0 1
0 1 1

Sample Output
1

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 运筹学排序问题中的在线排序
    • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
    • ¥30 求一段fortran代码用IVF编译运行的结果
    • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
    • ¥15 lammps拉伸应力应变曲线分析
    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题