Submission #24873609


Source Code Expand

h, w, n = map(int, input().split())

card = []
for i in range(n):
    a, b = map(int, input().split())
    card += [[i, a, b]]

row = sorted(card, key = lambda x:x[1])
col = sorted(card, key = lambda x:x[2])

res = [[] for _ in range(n)]

pr = -1
pc = -1
num = 0
for j, r, _ in row:
    if r != pr:
        num += 1
        res[j].append(num)
    else:
        res[j].append(num)
    pr = r

nn = 0
for j, _, c in col:
    if c != pc:
        nn += 1
        res[j].append(nn)
    else:
        res[j].append(nn)
    pc = c

for _ in range(n):
    print(*res[_])
        
    

Submission Info

Submission Time
Task C - Reorder Cards
User cubesat
Language Python (3.8.2)
Score 300
Code Size 615 Byte
Status AC
Exec Time 525 ms
Memory 46896 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 18 ms 9120 KiB
random_01.txt AC 23 ms 8948 KiB
random_02.txt AC 25 ms 8944 KiB
random_03.txt AC 442 ms 41088 KiB
random_04.txt AC 408 ms 38820 KiB
random_05.txt AC 525 ms 46896 KiB
random_06.txt AC 469 ms 40692 KiB
random_07.txt AC 462 ms 41312 KiB
random_08.txt AC 450 ms 40744 KiB
random_09.txt AC 455 ms 41244 KiB
random_10.txt AC 125 ms 15964 KiB
random_11.txt AC 25 ms 9232 KiB
random_12.txt AC 33 ms 9668 KiB
random_13.txt AC 74 ms 12776 KiB
random_14.txt AC 28 ms 9464 KiB
random_15.txt AC 32 ms 9748 KiB
random_16.txt AC 19 ms 8936 KiB
sample_01.txt AC 21 ms 9116 KiB
sample_02.txt AC 21 ms 8948 KiB