Submission #70038977


Source Code Expand

N,M = map(int,input().split())
U,V = [],[]
for _ in range(M):
    u,v = map(int,input().split())
    U.append(u-1)
    V.append(v-1)


def partition_generator(N: int):
    """
    (list, list): 2つのサブセットで構成されるタプル。
    """
    for i in range(2**N):
        subset1 = []
        subset2 = []
        for j in range(N):
            if (i >> j) & 1:
                # ビットが1ならsubset2へ
                subset2.append(j)
            else:
                # ビットが0ならsubset1へ
                subset1.append(j)
        yield (subset1, subset2)

m = 10**9 #最小回数
for p in partition_generator(N):
    #subset内でのエッジを検出
    count = 0
    for i in range(M):
        if (U[i] in p[0]) == (V[i] in p[0]):
            count += 1
    if count < m:
        m = count
print(m)

Submission Info

Submission Time
Task C - Bipartize
User exophia
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 873 Byte
Status AC
Exec Time 69 ms
Memory 82024 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 54 ms 76164 KiB
00_sample_01.txt AC 53 ms 76584 KiB
00_sample_02.txt AC 67 ms 81800 KiB
01_random_03.txt AC 54 ms 76420 KiB
01_random_04.txt AC 64 ms 81772 KiB
01_random_05.txt AC 54 ms 76268 KiB
01_random_06.txt AC 54 ms 76372 KiB
01_random_07.txt AC 65 ms 81920 KiB
01_random_08.txt AC 61 ms 81152 KiB
01_random_09.txt AC 65 ms 82024 KiB
01_random_10.txt AC 65 ms 81744 KiB
01_random_11.txt AC 66 ms 82000 KiB
01_random_12.txt AC 68 ms 81992 KiB
01_random_13.txt AC 68 ms 81944 KiB
01_random_14.txt AC 69 ms 81700 KiB
01_random_15.txt AC 65 ms 81700 KiB
01_random_16.txt AC 68 ms 81748 KiB
01_random_17.txt AC 54 ms 76600 KiB
01_random_18.txt AC 54 ms 76704 KiB
01_random_19.txt AC 54 ms 76424 KiB
01_random_20.txt AC 56 ms 81012 KiB
01_random_21.txt AC 53 ms 76316 KiB
01_random_22.txt AC 54 ms 76416 KiB
01_random_23.txt AC 53 ms 76304 KiB
01_random_24.txt AC 53 ms 76204 KiB