Problem hidden
|This problem was hidden by Editorial Board member probably because it has incorrect language|version or invalid test data, or description of the problem is not clear.|

FSOFT - Group separation

FSoft company has just employed N programmers. The leader wants them to be separated into M groups satisfying: each group's quantity is equal and each person is belong to only one group. After interviewing them and analyzing their CV(s), the leader has summarized the table A where Aij values the effect whether progammer i and j are in the same group.
The leader needs your help to find out the most effective separation. A separation's effect is the sum of all group's effect; each group's effect is the sum of all pair of person in that group.

Input

- The first line contains N, M.
- Next N line(s), each line contains N number describing the table A. (Aii=0; Aji=Aij)

Output

- The first line contains the effect of your separation.
- Next M lines contains the list of each group following your separation.

Example

Input:
4 2
0 1 2 3
1 0 5 1
2 5 0 2
3 1 2 0

Output:
8
1 4
2 3

Limitations

- 1 ≤ N ≤ 100.
- 1 ≤ M ≤ 10. (N mod M = 0)

Scoring

- There are 10 test cases; in each test case, let your separation's effect be RES, let the answer be ANS; if your written programmer list is logical, you will get the score = (RES/ANS)4x10.
- The overall score is the sum of the scores you got in each test case.


Được gửi lên bởi:AnhDQ
Ngày:2009-05-14
Thời gian chạy:0.400s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:Mr Khuong Nguyen Duy, College of Technology, VNU (Hanoi, Vietnam)

hide comments
2017-12-10 10:15:01
1 đấm ac nhé
2017-12-10 10:14:29
Duy ơi
2016-08-20 04:34:46
sub
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.