CF775A.University Schedule

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

In this problem your task is to come up with a week schedule of classes in university for professors and student groups. Consider that there are 66 educational days in week and maximum number of classes per educational day is 77 (classes numerated from 11 to 77 for each educational day).

It is known that in university nn students study, mm professors work and there are aa classrooms for conducting classes. Also you have two-dimensional array with n×mn×m size which contains the following information. The number which stays in ii -th row and jj -th column equals to the number of classes which professor jj must conduct with the group ii in a single week. The schedule which you output must satisfy to array described above.

There are several other conditions for schedule. Single professor can not conduct more than one class. Similarly, single student group can not be on more than one class at the same time.

Let define a fatigue function for professors and student groups. Call this function ff .

To single professor fatigue calculated in the following way. Let look on classes which this professor must conduct in each of the 66 -th educational days. Let xx be the number of class which professor will firstly conduct in day ii and let yy — the last class for this professor. Then the value (2+yx+1)(2+yx+1)(2+y-x+1)·(2+y-x+1) must be added to professor's fatigue. If professor has no classes in day ii , nothing is added to professor's fatigue.

For single student group fatigue is calculated similarly. Lets look at classes of this group in each of the 66 educational days. Let xx be the number of first class for this group on day ii and let yy — the last class for this group. Then the value (2+yx+1)(2+yx+1)(2+y-x+1)·(2+y-x+1) must be added to this group's fatigue. If student group has no classes in day ii , nothing is added to group's fatigue.

So the value of function ff equals to total {fatigue} for all nn student groups and for all mm professors.

Your task is to come up with such a schedule which minimizes the value of function ff .

Jury prepared some solution of this problem. For each test you will get a certain number of points. It equals to result of division of the value of function ff from the jury solution by the value of function ff for schedule which your program output (i. e. the smaller value of {fatigue} function your program find the more points you will get), multiplied by 100100 . In the other words if the value of ff for jury solution equals to pp and for your solution — to qq , you will get 100p/q100·p/q points (note, that the number of points is a real number). The points will be added together for all tests. The goal is to score as many points as possible.

输入格式

The first line contains three integers nn , mm and aa ( 1<=n,m,a<=601<=n,m,a<=60 ) — the number of groups, the number of professors and the number of classrooms.

Each of the following nn lines contains mm integers from 00 to 2424jj -th number in ii -th line equals to the number of classes with the professor jj must conduct with the ii -th student group.

It is guaranteed that the number of classes in week for each professor and for each student group does not exceed 2424 . Also guaranteed that the total number of classes in week does not exceed 7575 % from a maximum number of classes which can be conducted based on the number of classrooms. For all tests there is at least one schedule satisfying all described conditions.

输出格式

In the first line print the minimized value of function ff .

After that print blank line.

After that print the schedule for each student group in increasing order of group number. For each student group print 77 lines. Each line must contains 66 numbers. Let the number at ii -th line and jj -th column equals to xx . If in jj -th day current group has no class number ii , xx must be equals to zero. Otherwise xx must be equals to the number of professor who will conduct the corresponding class with the corresponding student group.

The number of classes which will be conducted simultaneously must not exceeds the number of classrooms aa .

Separate the description of the schedules for groups with a blank line.

输入输出样例

  • 输入#1

    3 3 1
    1 0 0
    0 1 0
    0 0 1
    

    输出#1

    54
    
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 0 0 0 0 
    2 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    3 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
  • 输入#2

    3 1 1
    1
    1
    1
    

    输出#2

    52
    
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 0 0 0 0 
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
  • 输入#3

    5 7 10
    1 3 6 0 1 2 4
    0 3 0 6 5 1 4
    3 5 1 2 3 2 4
    2 3 1 1 4 1 2
    2 4 3 2 4 3 2
    

    输出#3

    1512
    
    0 0 6 0 0 2 
    0 7 6 3 3 7 
    3 1 2 3 2 7 
    3 7 0 0 0 0 
    5 3 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 4 0 7 6 
    4 5 7 4 5 5 
    7 2 4 4 5 5 
    7 2 0 4 0 0 
    0 2 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    4 0 7 2 5 7 
    5 0 2 5 7 1 
    2 4 1 2 7 1 
    2 3 0 0 0 0 
    0 6 0 0 0 0 
    0 6 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 0 5 3 5 
    0 2 4 7 2 6 
    0 5 7 0 0 0 
    1 5 1 0 0 0 
    2 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    
    0 0 5 7 2 3 
    0 1 3 2 6 3 
    5 7 6 5 6 4 
    5 4 2 2 0 0 
    1 0 0 0 0 0 
    0 0 0 0 0 0 
    0 0 0 0 0 0 
    

说明/提示

During the main part of the competition (one week) you solution will be judged on 100100 preliminary tests. The first 1010 preliminary tests are available for download by a link http://assets.codeforces.com/files/vk/vkcup-2017-wr2-materials-v1.tar.gz.

After the end of the contest (i.e., a week after its start) the last solution you sent (having positive score) will be chosen to be launched on the extended final tests.

首页