AtCoder Beginner Contest 041

Submission #1333411

Source codeソースコード

N, M = map(int, input().split())
hayai_usagi = [0]*N
for i in range(M):
    x, y = map(int, input().split())
    hayai_usagi[y-1] += 1 << (x-1)

bit_max = 1 << N
dp = [0]*bit_max
dp[0] = 1

for bitset in range(bit_max):
    for usa_num in range(N):
        usa_bit = 1 << usa_num
        others = bitset - usa_bit
        if bitset & usa_bit and\
                hayai_usagi[usa_num] & others == hayai_usagi[usa_num]:
            dp[bitset] += dp[bitset - usa_bit]

print(dp[bit_max-1])

Submission

Task問題 D - 徒競走
User nameユーザ名 htkb
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 100
Source lengthソースコード長 504 Byte
File nameファイル名
Exec time実行時間 542 ms
Memory usageメモリ使用量 4892 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 0_00.txt,0_01.txt,0_02.txt
Subtask1 30 / 30 0_00.txt,0_01.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt
All 70 / 70 0_00.txt,0_01.txt,0_02.txt,1_00.txt,1_01.txt,1_02.txt,1_03.txt,1_04.txt,1_05.txt,1_06.txt,1_07.txt,1_08.txt,1_09.txt,1_10.txt,1_11.txt,1_12.txt,2_00.txt,2_01.txt,2_02.txt,2_03.txt,2_04.txt,2_05.txt,2_06.txt,2_07.txt,2_08.txt,2_09.txt,2_10.txt,2_11.txt,2_12.txt,2_13.txt,2_14.txt,2_15.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_00.txt AC 17 ms 3060 KB
0_01.txt AC 17 ms 3064 KB
0_02.txt AC 494 ms 4892 KB
1_00.txt AC 17 ms 3064 KB
1_01.txt AC 18 ms 3064 KB
1_02.txt AC 18 ms 3064 KB
1_03.txt AC 18 ms 3060 KB
1_04.txt AC 18 ms 3060 KB
1_05.txt AC 17 ms 3064 KB
1_06.txt AC 17 ms 3060 KB
1_07.txt AC 18 ms 3064 KB
1_08.txt AC 17 ms 3064 KB
1_09.txt AC 18 ms 3064 KB
1_10.txt AC 18 ms 3064 KB
1_11.txt AC 18 ms 3064 KB
1_12.txt AC 18 ms 3064 KB
2_00.txt AC 542 ms 4892 KB
2_01.txt AC 408 ms 3572 KB
2_02.txt AC 438 ms 3572 KB
2_03.txt AC 460 ms 3572 KB
2_04.txt AC 215 ms 3316 KB
2_05.txt AC 225 ms 3316 KB
2_06.txt AC 224 ms 3316 KB
2_07.txt AC 199 ms 3316 KB
2_08.txt AC 453 ms 3572 KB
2_09.txt AC 439 ms 3572 KB
2_10.txt AC 414 ms 3572 KB
2_11.txt AC 397 ms 3572 KB
2_12.txt AC 532 ms 3572 KB
2_13.txt AC 448 ms 3572 KB
2_14.txt AC 457 ms 3572 KB
2_15.txt AC 459 ms 3752 KB