AtCoder Beginner Contest 041

Submission #788008

Source codeソースコード

import sys
stdin = sys.stdin
def na(): return map(int, stdin.readline().split())
def ns(): return stdin.readline().strip()

n,m = na()

rule = [0]*n
for i in range(m):
    x,y = na()
    rule[y-1] |= 1<<x-1

u = 1<<n
dp = [0]*u
dp[0] = 1
for i in range(u):
    for j in range(n):
        if i>>j&1:
            k = i^1<<j
            if (rule[j]&k) == rule[j]:
                dp[i] += dp[k]
print(dp[u-1])

Submission

Task問題 D - 徒競走
User nameユーザ名 うい
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 100
Source lengthソースコード長 429 Byte
File nameファイル名
Exec time実行時間 734 ms
Memory usageメモリ使用量 4944 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 38 ms 3064 KB
0_01.txt AC 37 ms 3064 KB
0_02.txt AC 734 ms 4944 KB
1_00.txt AC 39 ms 3064 KB
1_01.txt AC 38 ms 3064 KB
1_02.txt AC 38 ms 3064 KB
1_03.txt AC 40 ms 3064 KB
1_04.txt AC 40 ms 3064 KB
1_05.txt AC 38 ms 3064 KB
1_06.txt AC 38 ms 3064 KB
1_07.txt AC 37 ms 3064 KB
1_08.txt AC 37 ms 3064 KB
1_09.txt AC 39 ms 3064 KB
1_10.txt AC 39 ms 3064 KB
1_11.txt AC 39 ms 3064 KB
1_12.txt AC 39 ms 3064 KB
2_00.txt AC 723 ms 4944 KB
2_01.txt AC 599 ms 3572 KB
2_02.txt AC 597 ms 3572 KB
2_03.txt AC 623 ms 3572 KB
2_04.txt AC 315 ms 3316 KB
2_05.txt AC 310 ms 3316 KB
2_06.txt AC 309 ms 3316 KB
2_07.txt AC 300 ms 3316 KB
2_08.txt AC 653 ms 3572 KB
2_09.txt AC 597 ms 3572 KB
2_10.txt AC 628 ms 3572 KB
2_11.txt AC 607 ms 3572 KB
2_12.txt AC 690 ms 3572 KB
2_13.txt AC 681 ms 3572 KB
2_14.txt AC 662 ms 3572 KB
2_15.txt AC 693 ms 3788 KB