CF411B.Multi-core Processor

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The research center Q has developed a new multi-core processor. The processor consists of nn cores and has kk cells of cache memory. Consider the work of this processor.

At each cycle each core of the processor gets one instruction: either do nothing, or the number of the memory cell (the core will write an information to the cell). After receiving the command, the core executes it immediately. Sometimes it happens that at one cycle, multiple cores try to write the information into a single cell. Unfortunately, the developers did not foresee the possibility of resolving conflicts between cores, so in this case there is a deadlock: all these cores and the corresponding memory cell are locked forever. Each of the locked cores ignores all further commands, and no core in the future will be able to record an information into the locked cell. If any of the cores tries to write an information into some locked cell, it is immediately locked.

The development team wants to explore the deadlock situation. Therefore, they need a program that will simulate the processor for a given set of instructions for each core within mm cycles . You're lucky, this interesting work is entrusted to you. According to the instructions, during the mm cycles define for each core the number of the cycle, during which it will become locked. It is believed that initially all cores and all memory cells are not locked.

输入格式

The first line contains three integers nn , mm , kk (1<=n,m,k<=100)(1<=n,m,k<=100) . Then follow nn lines describing instructions. The ii -th line contains mm integers: xi1,xi2,...,ximx_{i1},x_{i2},...,x_{im} (0<=xij<=k)(0<=x_{ij}<=k) , where xijx_{ij} is the instruction that must be executed by the ii -th core at the jj -th cycle. If xijx_{ij} equals 0, then the corresponding instruction is «do nothing». But if xijx_{ij} is a number from 1 to kk , then the corresponding instruction is «write information to the memory cell number xijx_{ij} ».

We assume that the cores are numbered from 1 to nn , the work cycles are numbered from 1 to mm and the memory cells are numbered from 1 to kk .

输出格式

Print nn lines. In the ii -th line print integer tit_{i} . This number should be equal to 0 if the ii -th core won't be locked, or it should be equal to the number of the cycle when this core will be locked.

输入输出样例

  • 输入#1

    4 3 5
    1 0 0
    1 0 2
    2 3 1
    3 2 0
    

    输出#1

    1
    1
    3
    0
    
  • 输入#2

    3 2 2
    1 2
    1 2
    2 2
    

    输出#2

    1
    1
    0
    
  • 输入#3

    1 1 1
    0
    

    输出#3

    0
    
首页