TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The PDF file of all problems can be downloaded HERE

Input Format

Output Format

Sample Input 1

2
2 3
001
111
3 3
001
011
000

Sample Output 1

Case 1: row 1
Case 2: both 2

Hints

Explanation of sample input and output:

Case 1


The initial matrix is:

001

111


If we swap values of cell (1, 1) and cell (2, 1), the matrix will become

101

011


Now each row has two 1s and we found the solution.


Case 2


The initial matrix is:

001

011

000


If we swap the values of cell (2, 1) and cell (2, 3) (Considering the matrix wraps), the matrix will become

001

110

000


If we swap the values of cell (2, 1) and cell (3, 1), the matrix will become.

001

010

100


Now each row has one 1 and each column has one 1 and we got our solution.

Problem Source

Migrated from old NTUJ.

Regional Dhaka 2011

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 1000 65536 200