|Nộp bài||Các bài nộp||Làm tốt nhất||Về danh sách bài|
MPART - Group Partition
Jamie is a very popular girl and has quite a lot of friends, so she always keeps a very long contact list in her cell phone. The lontact list has become so long that it often takes a long time for her to browse through the whole list to find a friend’s number.
As Jamie’s best friend and a programming genius, you suggest that she group the contact list and minimize the size of the largest group, so that it will be easier for her to search for a friend’s number among the groups. Jamie takes your advice and gives you her entire contact list containing her friends’ names, the number of groups she wishes to have and what groups every friend could belong to.
Your task is to write a program that takes the list and organizes it into groups such that each friend appears in only one of those groups and the size of the largest group is minimized.
There will be at most 20 test cases. Ease case starts with a line containing two integers N and M. where N is the length of the contact list and M is the number of groups.
N lines then follow. Each line contains a friend’s name and the groups the friend could belong to. You can assume N is no more than 1000 and M is no more than 500. The names will contain alphabet letters only and will be no longer than 15 characters. No two friends have the same name. The group label is an integer between 0 and M-1.
After the last test case, there is a single line “0 0” that terminates the input.Sample Input
3 2 John 0 1 Rose 1 Mary 1 5 4 ACM 1 2 3 ICPC 0 1 Asian 0 2 3 Regional 1 2 ShangHai 0 2 0 0
For each test case, output a line containing a single integer, the size of the largest contact group.Sample output
2 2Note : Huge data input
|Được gửi lên bởi:||psetter|
|Thời gian chạy:||1s-6.752s|
|Giới hạn mã nguồn:||50000B|
|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:||Shanghai 2004|
2015-09-19 08:45:21 Nguyá»…n Viá»‡t Tháº¯ng
làm luồng bình thường vẫn AC đc.
2009-03-19 23:33:41 ~!(*(@*!@^&
Rejudge lai cho RR: test 1 - WA (score=0.000000, sig=0, time=100.160000, mem=32896)
2009-03-19 23:33:26 ~!(*(@*!@^&
Muon AC bang luong <5s thi phai cai Dinic algorithm.
Last edit: 2009-03-19 23:33:26