Submission #4071119


Source Code Expand

N,C,E = map(int, input().split())
girls = map(int, input().split())
e = []
for _ in range(E):
    a,b = map(int, input().split())
    e.append((a,b))

visit = [False]*N
def dfs(i:int):
    global visit,e
    if visit[i]: return
    else: visit[i] = True
    # print(i)
    nex = []
    for ej in e:
        if ej[0]==i:   nex.append(ej[1])
        elif ej[1]==i: nex.append(ej[0])
    for nexi in nex:
        dfs(nexi)

        
ans  = 1e9
for comb in range(1<<E):
    cnt = 0
    cur_e = []
    visit = [False]*N
    for j in range(E):
        if (comb>>j)&1==1: cur_e.append(e[j])
        else:  cnt += 1
    # print(cur_e)

    dfs(0)
    cnt = 0
    for gi in girls:
        if not visit[gi]:
            cnt += 1
    ans = min(ans, cnt)
print(ans)

Submission Info

Submission Time
Task D - 浮気予防
User odanny
Language Python (3.4.3)
Score 0
Code Size 790 Byte
Status WA
Exec Time 2104 ms
Memory 3484 KB

Judge Result

Set Name part All
Score / Max Score 0 / 99 0 / 1
Status
AC × 17
WA × 10
AC × 19
WA × 18
TLE × 24
Set Name Test Cases
part test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_41_AB.txt, test_47_AB.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_26_A.txt, test_27_A.txt, test_28_A.txt, test_29_A.txt, test_30_A.txt, test_31_A.txt, test_32_A.txt, test_33_A.txt, test_34_A.txt, test_35_A.txt, test_36_A.txt, test_37_A.txt, test_38_A.txt, test_39_A.txt, test_40_A.txt, test_41_AB.txt, test_42_A.txt, test_43_A.txt, test_44_A.txt, test_45_A.txt, test_46_A.txt, test_47_AB.txt, test_48_A.txt, test_49_A.txt, test_50_A.txt, test_51_A.txt
Case Name Status Exec Time Memory
sample_01.txt WA 18 ms 3064 KB
sample_02.txt WA 18 ms 3064 KB
sample_03.txt WA 59 ms 3064 KB
sample_04.txt WA 18 ms 3064 KB
sample_05.txt AC 18 ms 3064 KB
test_01_AB.txt AC 18 ms 3064 KB
test_02_AB.txt WA 110 ms 3064 KB
test_03_AB.txt WA 110 ms 3188 KB
test_04_AB.txt WA 113 ms 3064 KB
test_05_AB.txt WA 50 ms 3064 KB
test_06_AB.txt AC 18 ms 3064 KB
test_07_AB.txt AC 18 ms 3064 KB
test_08_AB.txt WA 18 ms 3064 KB
test_09_AB.txt AC 18 ms 3064 KB
test_10_AB.txt AC 18 ms 3064 KB
test_11_AB.txt WA 19 ms 3064 KB
test_12_AB.txt AC 18 ms 3064 KB
test_13_AB.txt AC 29 ms 3064 KB
test_14_AB.txt AC 18 ms 3064 KB
test_15_AB.txt AC 19 ms 3064 KB
test_16_AB.txt AC 18 ms 3064 KB
test_17_AB.txt WA 17 ms 3064 KB
test_18_AB.txt AC 40 ms 3064 KB
test_19_AB.txt AC 20 ms 3064 KB
test_20_AB.txt AC 18 ms 3064 KB
test_21_AB.txt AC 41 ms 3064 KB
test_22_AB.txt WA 19 ms 3064 KB
test_23_AB.txt WA 18 ms 3064 KB
test_24_AB.txt AC 18 ms 3064 KB
test_25_AB.txt AC 18 ms 3064 KB
test_26_A.txt TLE 2104 ms 3444 KB
test_27_A.txt TLE 2104 ms 3484 KB
test_28_A.txt TLE 2104 ms 3444 KB
test_29_A.txt TLE 2104 ms 3444 KB
test_30_A.txt TLE 2104 ms 3444 KB
test_31_A.txt TLE 2104 ms 3444 KB
test_32_A.txt TLE 2104 ms 3064 KB
test_33_A.txt TLE 2104 ms 3188 KB
test_34_A.txt TLE 2104 ms 3064 KB
test_35_A.txt TLE 2104 ms 3064 KB
test_36_A.txt TLE 2104 ms 3064 KB
test_37_A.txt TLE 2104 ms 3188 KB
test_38_A.txt TLE 2104 ms 3064 KB
test_39_A.txt TLE 2104 ms 3064 KB
test_40_A.txt TLE 2104 ms 3064 KB
test_41_AB.txt AC 18 ms 3064 KB
test_42_A.txt TLE 2104 ms 3188 KB
test_43_A.txt TLE 2104 ms 3064 KB
test_44_A.txt TLE 2104 ms 3064 KB
test_45_A.txt TLE 2104 ms 3064 KB
test_46_A.txt TLE 2104 ms 3064 KB
test_47_AB.txt WA 18 ms 3064 KB
test_48_A.txt TLE 2104 ms 3064 KB
test_49_A.txt TLE 2104 ms 3064 KB
test_50_A.txt TLE 2104 ms 3064 KB
test_51_A.txt TLE 2104 ms 3064 KB