CF226D.The table
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Harry Potter has a difficult homework. Given a rectangular table, consisting of n × m cells. Each cell of the table contains the integer. Harry knows how to use two spells: the first spell change the sign of the integers in the selected row, the second — in the selected column. Harry's task is to make non-negative the sum of the numbers in each row and each column using these spells.
Alone, the boy can not cope. Help the young magician!
哈利·波特有一项困难的作业。给定一个由 n×m 个单元格组成的矩形表格,每个单元格中包含一个整数。哈利知道如何使用两种魔法:第一种魔法可以翻转所选行中所有整数的符号;第二种魔法可以翻转所选列中所有整数的符号。哈利的任务是通过使用这些魔法,使得每一行以及每一列中数字的和均为非负数。
单凭他自己无法完成这项任务。请帮助这位年轻的魔法师!
输入格式
The first line contains two integers n and m (1 ≤ n, m ≤ 100) — the number of rows and the number of columns.
Next n lines follow, each contains m integers: j-th integer in the i-th line is a__i, j (|a__i, j| ≤ 100), the number in the i-th row and j-th column of the table.
The rows of the table numbered from 1 to n. The columns of the table numbered from 1 to m.
第一行包含两个整数 n 和 m(1≤n,m≤100)—— 分别表示表格的行数和列数。
接下来的 n 行中,每行包含 m 个整数:第 i 行中的第 j 个整数为 ai,j(∣ai,j∣≤100),即表格第 i 行、第 j 列中的数值。
表格的行编号从 1 到 n,列编号从 1 到 m。
输出格式
In the first line print the number a — the number of required applications of the first spell. Next print a space-separated integers — the row numbers, you want to apply a spell. These row numbers must be distinct!
In the second line print the number b — the number of required applications of the second spell. Next print b space-separated integers — the column numbers, you want to apply a spell. These column numbers must be distinct!
If there are several solutions are allowed to print any of them.
第一行输出整数 a —— 表示需要施放第一种法术的次数。接下来输出 a 个用空格分隔的整数 —— 表示你希望施放法术的行号。这些行号必须互不相同!
第二行输出整数 b —— 表示需要施放第二种法术的次数。接下来输出 b 个用空格分隔的整数 —— 表示你希望施放法术的列号。这些列号必须互不相同!
若存在多种解,输出任意一种即可。
输入输出样例
输入#1
4 1 -1 -1 -1 -1
输出#1
4 1 2 3 4 0
输入#2
2 4 -1 -1 -1 2 1 1 1 1
输出#2
1 1 1 4
输入解题思路,AI测评打分。不知道怎么写?