s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s380560989
p03805
u094191970
1571377714
Python
Python (3.4.3)
py
Runtime Error
30
3064
467
from itertools import permutations n,m=map(int,input().split()) tree=[[] for i in range(m)] for i in range(m): a,b=map(int,input().split()) tree[a-1].append(b-1) tree[b-1].append(a-1) cnt=0 for i in permutations(range(1,n)): if i[0] in tree[0]: t_cnt=1 for j in range(1,len(i)): ...
s346829767
p03805
u094191970
1571377656
Python
Python (3.4.3)
py
Runtime Error
30
3064
467
from itertools import permutations n,m=map(int,input().split()) tree=[[] for i in range(m)] for i in range(m): a,b=map(int,input().split()) tree[a-1].append(b-1) tree[b-1].append(a-1) cnt=0 for i in permutations(range(1,n)): if i[0] in tree[0]: t_cnt=1 for j in range(1,len(i)): ...
s082189523
p03805
u094191970
1571377367
Python
PyPy3 (2.4.0)
py
Runtime Error
2106
42632
427
from itertools import permutations n,m=map(int,input().split()) tree=[[] for i in range(m)] for i in range(m): a,b=map(int,input().split()) tree[a-1].append(b-1) tree[b-1].append(a-1) cnt=0 for i in permutations(range(1,m)): if i[0] in tree[0]: t_cnt=1 for j in range(1,len(i)): ...
s473001470
p03805
u094191970
1571376735
Python
Python (3.4.3)
py
Runtime Error
2104
3064
427
from itertools import permutations n,m=map(int,input().split()) tree=[[] for i in range(m)] for i in range(m): a,b=map(int,input().split()) tree[a-1].append(b-1) tree[b-1].append(a-1) cnt=0 for i in permutations(range(1,m)): if i[0] in tree[0]: t_cnt=1 for j in range(1,len(i)): ...
s708453802
p03805
u022154897
1571179107
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38512
676
from collections import defaultdict def c(): n, m = map(int, input().split()) graph = defaultdict(list) a1 = None for i in range(n): a, b = map(int, input().split()) if i == 0: a1 = a graph[a].append(b) graph[b].append(a) stack = [] count = 0 if ...
s197289338
p03805
u123648284
1570915039
Python
Python (3.4.3)
py
Runtime Error
18
3064
418
def bfs(u): if used.count(True) == N: res[0] += 1 return for v in adj[u]: if used[v]: continue used[v] = True bfs(v) used[v] = False N, M = map(int, input().split()) adj = [[] for i in range(N)] for i in range(N): u, v = map(lambda x: int(x)-1, input().split()) adj[u].append(v) ...
s446103400
p03805
u223646582
1569988203
Python
Python (3.4.3)
py
Runtime Error
19
3064
376
import itertools N, M = map(int, input().split()) G = {k: set() for k in range(N+1)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a].add(b) G[b].add(a) ans = 0 for p in itertools.permutations(range(2, N+1)): c = 1 for n in p: if n not in G[c]: break ...
s082370707
p03805
u893478938
1569682768
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38384
550
def resolve(): N,M = map(int,input().split()) ab =[map(int,input().split()) for _ in range(N)] branch = [[] for _ in range(N)] for a,b in ab: branch[a-1].append(b-1) branch[b-1].append(a-1) bit = 0 count = 0 def walk(p): nonlocal bit,N bit |= (1 << p) ...
s154625798
p03805
u090267744
1569641258
Python
Python (3.4.3)
py
Runtime Error
17
2940
652
#C One-stroke Path import itertools import numpy as np n,m=map(int,input().split( )) adj_matrix=np.zeros((n,n)) for i in range(m): a,b=map(int,input().split( )) adj_matrix[a-1,b-1]=1 adj_matrix[b-1,a-1]=1 cnt=0 for each in itertools.permutations(range(n)): #頂点の全ての並べ方(permutation) if each[0] != 0:#始点...
s601057728
p03805
u780962115
1569464201
Python
Python (3.4.3)
py
Runtime Error
18
3064
517
n,m=map(int,input().split()) uselist=[] for _ in range(m): ad=list(map(int,input().split())) uselist.append(ad) cnt=0 for i in itertools.permutations(range(1,n+1)): if i[0]==1: flag=True for j in range(n-1): if [i[j],i[j+1]] not in uselist and [i[j+1], i[j]] not in uselist: ...
s364094263
p03805
u598229387
1569341938
Python
Python (3.4.3)
py
Runtime Error
32
3064
378
import itertools n,m=map(int,input().split()) edge=[[]for i in range(m+1)] for i in range(m): a,b=map(int,input().split()) edge[a].append(b) edge[b].append(a) ans=0 for i in itertools.permutations(range(1,n+1)): if i[0]!=1: continue for j in range(n-1): if i[j+1] not in edge[i[...
s023435645
p03805
u433532588
1568946241
Python
Python (3.4.3)
py
Runtime Error
18
3064
747
import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # A = [ int(input()) for _ in range(N) ] ############################## N, M = map(int, input().split()) A = [ [0 for _ in range(N)] for _ in range(N) ] visited = [False] * N for i in range(M): a, b = map(int, i...
s142688517
p03805
u433532588
1568946158
Python
Python (3.4.3)
py
Runtime Error
18
3064
737
import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # A = [ int(input()) for _ in range(N) ] ############################## N, M = map(int, input().split()) A = [ [0 for _ in range(N)] for _ in range(N) ] visited = [False] * N for i in range(M): a, b = map(int, i...
s954840983
p03805
u432551953
1568860671
Python
Python (3.4.3)
py
Runtime Error
92
3064
529
import sys input = sys.stdin.readline from operator import itemgetter import itertools def main(): n, m = map(int, input().strip().split()) lis = [[] for _ in range(n)] for _ in range(m): a, b = list(map(lambda x: x-1, map(int, input().strip().split()))) lis[a].append(b) lis[b].appe...
s754151809
p03805
u432551953
1568860594
Python
PyPy3 (2.4.0)
py
Runtime Error
216
43116
529
import sys input = sys.stdin.readline from operator import itemgetter import itertools def main(): n, m = map(int, input().strip().split()) lis = [[] for _ in range(n)] for _ in range(m): a, b = list(map(lambda x: x-1, map(int, input().strip().split()))) lis[a].append(b) lis[b].appe...
s351104205
p03805
u378328623
1568754734
Python
Python (3.4.3)
py
Runtime Error
17
3064
521
N, M = map(int, input().split()) edgelist = [] for i in range(N): edgelist.append(set(map(int, input().split()))) s = [1] count = 0 L = [[i for i in edgelist if (len(i&set([1]))!=0)]] while s != []: if len(s) == M: count = count + 1 L.pop() s.pop() elif L[-1] == []: L.pop() ...
s074223224
p03805
u325227960
1568700958
Python
PyPy3 (2.4.0)
py
Runtime Error
186
40816
553
n, m = map(int,input().split()) A = [list(map(int,input().split())) for i in range(n)] import itertools M = [[0] * (n+1) for i in range(n+1)] for i in range(m): M[A[i][0]][A[i][1]] = 1 M[A[i][1]][A[i][0]] = 1 B = list(itertools.permutations(range(2, n+1))) #print(B) ans = 0 for i in range(len(B)): pt =...
s395670796
p03805
u390883247
1568537381
Python
Python (3.4.3)
py
Runtime Error
31
3064
597
import itertools N,M = map(int,input().split()) Data = [] for _ in range(M+1): Data.append([0]*(M+1)) for _ in range(M): a,b = map(int,input().split()) Data[a][b] = 1 Data[b][a] = 1 ans = 0 for r in itertools.permutations(range(2,N+1)): Rlist = list(r) a = 1 b = Rlist[0] if Data[a][b] ...
s980251120
p03805
u189326411
1568076671
Python
Python (3.4.3)
py
Runtime Error
26
3064
445
import itertools n,m = map(int, input().split()) path = [[False]*n for _ in range(n)] for i in range(n): a,b = map(int, input().split()) a -= 1 b -= 1 path[a][b]=True path[b][a]=True ans = 0 for i in itertools.permutations(range(n),n): if i[0]==0: for j in range(n): if j==...
s111643800
p03805
u311379832
1567997619
Python
Python (3.4.3)
py
Runtime Error
25
3064
579
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N, M = map(int, input().split()) tLst = [[] for _ in range(M)] vLst = [0] * N for i in range(M): a, b = map(int, input().split()) tLst[a - 1].append(b - 1) tLst[b - 1].append(a - 1) def dfs(n, index, v, ans): vLst[index] = 1 if ...
s928217085
p03805
u871841829
1567983782
Python
Python (3.4.3)
py
Runtime Error
22
3444
674
import copy N, M = list(map(int, input().split())) graph = [[-1 for _ in range(N)] for __ in range(N)] cnt = 0 def solve(current: int, traversed: set): global cnt traversed = copy.copy(traversed) # fail if current in traversed: return else: traversed.add(current) # success ...
s883623200
p03805
u463858127
1567662716
Python
Python (3.4.3)
py
Runtime Error
24
3064
546
# import sys # sys.setrecursionlimit(10**9) N, M = map(int, input().split()) Map = [[] for _ in range(M)] reached = [False]*N for _ in range(M): aa, bb = map(int, input().split()) Map[aa-1].append(bb-1) Map[bb-1].append(aa-1) cnt = 0 def DFS(x): global cnt global reached reached[x] = True ...
s708746231
p03805
u463858127
1567662644
Python
Python (3.4.3)
py
Runtime Error
24
3064
542
import sys sys.setrecursionlimit(10**9) N, M = map(int, input().split()) Map = [[] for _ in range(M)] reached = [False]*N for _ in range(M): aa, bb = map(int, input().split()) Map[aa-1].append(bb-1) Map[bb-1].append(aa-1) cnt = 0 def DFS(x): global cnt global reached reached[x] = True ...
s126141309
p03805
u463858127
1567555319
Python
Python (3.4.3)
py
Runtime Error
17
3064
502
import sys sys.setrecursionlimit(10**20) N, M = map(int, input().split()) Map = [[] for _ in range(M)] reached = [False]*N for _ in range(M): aa, bb = map(int, input().split()) Map[aa-1].append(bb-1) Map[bb-1].append(aa-1) cnt = 0 def DFS(x): global cnt reached[x] = True if all(reached): ...
s099676803
p03805
u463858127
1567554204
Python
Python (3.4.3)
py
Runtime Error
31
3064
501
import sys sys.setrecursionlimit(10**9) N, M = map(int, input().split()) Map = [[] for _ in range(M)] reached = [False]*N for _ in range(M): aa, bb = map(int, input().split()) Map[aa-1].append(bb-1) Map[bb-1].append(aa-1) cnt = 0 def DFS(x): global cnt reached[x] = True if all(reached): ...
s513593014
p03805
u463858127
1567552923
Python
Python (3.4.3)
py
Runtime Error
32
3064
511
import sys sys.setrecursionlimit(10**9) N, M = map(int, input().split()) Map = [[] for _ in range(M)] reached = [False]*N for _ in range(M): aa, bb = map(int, input().split()) Map[aa-1].append(bb-1) Map[bb-1].append(aa-1) cnt = 0 def DFS(x, pre): global cnt reached[x] = True if all(reached...
s925261895
p03805
u408620326
1567458860
Python
Python (3.4.3)
py
Runtime Error
19
3064
557
N, M = [int(x) for x in input().split()] P = [[False] * M for m in range(M)] dict={} for m in range(M): a, b = [int(x) for x in input().split()] P[a-1][b-1] = True P[b-1][a-1] = True def dp(x, past): past[x] = True if (x, tuple(past)) in dict: return dict[(x, tuple(past))] if False not in past: ret...
s715643418
p03805
u408620326
1567385732
Python
Python (3.4.3)
py
Runtime Error
43
3064
566
import sys sys.setrecursionlimit(1000000) N, M = [int(x) for x in input().split()] P = [[False] * M for m in range(M)] dict={} for m in range(M): a, b = [int(x) for x in input().split()] P[a-1][b-1] = True P[b-1][a-1] = True def dp(x, past): if (x, tuple(past)) in dict: return dict[(x, tuple(past))] past...
s097575178
p03805
u408620326
1567385710
Python
Python (3.4.3)
py
Runtime Error
42
3188
564
import sys sys.setrecursionlimit(10000) N, M = [int(x) for x in input().split()] P = [[False] * M for m in range(M)] dict={} for m in range(M): a, b = [int(x) for x in input().split()] P[a-1][b-1] = True P[b-1][a-1] = True def dp(x, past): if (x, tuple(past)) in dict: return dict[(x, tuple(past))] past[x...
s991310077
p03805
u408620326
1567385276
Python
Python (3.4.3)
py
Runtime Error
44
3316
524
N, M = [int(x) for x in input().split()] P = [[False] * M for m in range(M)] dict={} for m in range(M): a, b = [int(x) for x in input().split()] P[a-1][b-1] = True P[b-1][a-1] = True def dp(x, past): if (x, tuple(past)) in dict: return dict[(x, tuple(past))] past[x] = True if False not in past: ret...
s268738903
p03805
u408620326
1567384703
Python
Python (3.4.3)
py
Runtime Error
34
3064
420
N, M = [int(x) for x in input().split()] P = [[False] * M for m in range(M)] for m in range(M): a, b = [int(x) for x in input().split()] P[a-1][b-1] = True P[b-1][a-1] = True def dp(x, past): past[x] = True if False not in past: return 1 ret = 0 for i,p in enumerate(P[x]): if not p or x == i or p...
s762852481
p03805
u500297289
1567024098
Python
Python (3.4.3)
py
Runtime Error
1822
708980
451
import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) edge = [[] for _ in range(N + 1)] ab = [list(map(int, input().split())) for _ in range(M)] for i in range(M): a, b = ab[i][0], ab[i][1] edge[a].append(b) edge[b].append(a) def f(now, v): v = v & (1 << now) for to in edge[n...
s927486416
p03805
u981931040
1566951152
Python
Python (3.4.3)
py
Runtime Error
27
3064
603
n , m = map(int , input().split()) edge = [[] for _ in range(m) ] #print(edge) for _ in range(m): a , b = map(int , input().split()) a -= 1 ; b -= 1 edge[a].append(b) edge[b].append(a) #print(edge) def DFS(s): global visited #ret=1 if all(visited) else 0 if all(visited): ret = 1 ...
s661195235
p03805
u981931040
1566950668
Python
Python (3.4.3)
py
Runtime Error
28
3064
603
n , m = map(int , input().split()) edge = [[] for _ in range(m) ] #print(edge) for _ in range(m): a , b = map(int , input().split()) a -= 1 ; b -= 1 edge[a].append(b) edge[b].append(a) #print(edge) def DFS(s): global visited #ret=1 if all(visited) else 0 if all(visited): ret = 1 ...
s813933110
p03805
u981931040
1566950569
Python
Python (3.4.3)
py
Runtime Error
18
3064
583
n , m = map(int , input().split()) edge = [[] for _ in range(m) ] #print(edge) for _ in range(m): a , b = map(int , input().split()) a -= 1 ; b -= 1 edge[a].append(b) edge[b].append(a) #print(edge) def DFS(s): global visited #ret=1 if all(visited) else 0 if all(visited): ret = 1 ...
s118451669
p03805
u981931040
1566950518
Python
Python (3.4.3)
py
Runtime Error
17
3064
581
n , m = map(int , input().split()) edge = [[] for _ in range(m) ] #print(edge) for _ in range(m): a , b = map(int , input().split()) a -= 1 ; b -= 1 edge[a].append(b) edge[b].append(a) print(edge) def DFS(s): global visited #ret=1 if all(visited) else 0 if all(visited): ret = 1 ...
s112472451
p03805
u155687575
1566768383
Python
PyPy3 (2.4.0)
py
Runtime Error
201
40560
414
import itertools n, m = map(int, input().split()) adj_matrix = [[0] * n for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) adj_matrix[a-1][b-1] = 1 adj_matrix[b-1][a-1] = 1 cnt = 0 for each in range(itertools.permutations(range(n))): if each[0] != 0: break flag = 1 ...
s688003401
p03805
u433532588
1566701375
Python
Python (3.4.3)
py
Runtime Error
17
3064
745
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) ############################## # N = 頂点の数(= 数字の数) # M = 辺の数(= aの行数) N, M = map(int, input().split()) graph = [ [0 for _ in range(N)] for _ in range(N) ] visited = [False] * N for i in range(N): a, b = map(int, input().split()) graph[a-1][b-1...
s724537166
p03805
u433532588
1566701245
Python
Python (3.4.3)
py
Runtime Error
17
3064
679
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) ############################## N, M = map(int, input().split()) graph = [ [0 for _ in range(M)] for _ in range(M) ] visited = [False] * M for i in range(N): a, b = map(int, input().split()) graph[a-1][b-1] = 1 graph[b-1][a-1] = 1 #print(...
s014526694
p03805
u433532588
1566700991
Python
Python (3.4.3)
py
Runtime Error
18
3064
689
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) ############################## N, M = map(int, input().split()) graph = [ [0 for _ in range(M)] for _ in range(M) ] visited = [False] * M for i in range(N): a, b = map(int, input().split()) graph[a-1][b-1] = 1 graph[b-1][a-1] = 1 #print(...
s162574050
p03805
u433532588
1566700743
Python
Python (3.4.3)
py
Runtime Error
18
3188
698
import sys input = sys.stdin.readline sys.setrecursionlimit(10**6) ############################## N, M = map(int, input().split()) graph = [ [0 for _ in range(M)] for _ in range(M) ] visited = [False] * M for i in range(N): a, b = map(int, input().split()) graph[a-1][b-1] = 1 graph[b-1][a-1] = 1 #print(...
s464177201
p03805
u531436689
1566413301
Python
Python (3.4.3)
py
Runtime Error
68
6684
1130
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools from collections import deque sys.setrecursionlimit(10**7) inf = 10**20 mod = 10**9 + 7 DR = [1, -1, 0, 0] DC = [0, 0, 1, -1] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(...
s983211975
p03805
u852517668
1566322596
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38384
419
from collections import deque N, M = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(M): a, b = list(map(int, input().split())) G[a-1].append(b-1) G[b-1].append(a-1) ans = 0 v = 0 s = 1 l = 1 q = deque() q.append((v, s, l)) while q: v, s, l = q.popleft() if l == N: ans += 1 ...
s360723847
p03805
u850491413
1565949298
Python
Python (3.4.3)
py
Runtime Error
18
3064
680
N, M = list(map(int,input().split())) graph = [dict() for i in range(N)] for i in range(N): graph[i]["edge"] = [] for i in range(M): a, b = list(map(int, input().split())) graph[a - 1]["edge"].append(b - 1) graph[b - 1]["edge"].append(a - 1) def pow(N): ans = 1 for i in range(N): ans *= i + 1 return ans to...
s441126996
p03805
u098420017
1565845556
Python
Python (3.4.3)
py
Runtime Error
18
3064
496
n,m = map(int,input().split()) l=[[*map(int,input().split())] for _ in range(m)] i=[[] for _ in range(max(n,m))] i[0]=[1] c=1 for i_1 in i: for i_2 in i_1: a=[] for k in l: if i_2 in k: a.append(k) else: continue for b in a: if b[0]==i_2: ...
s038805886
p03805
u098420017
1565844965
Python
Python (3.4.3)
py
Runtime Error
17
3064
490
n,m = map(int,input().split()) l=[[*map(int,input().split())] for _ in range(m)] i=[[] for _ in range(m)] i[0]=[1] c=1 for i_1 in i: for i_2 in i_1: a=[] for k in l: if i_2 in k: a.append(k) else: continue for b in a: if b[0]==i_2: ...
s637705728
p03805
u098420017
1565844734
Python
Python (3.4.3)
py
Runtime Error
18
3064
490
n,m = map(int,input().split()) l=[[*map(int,input().split())] for _ in range(m)] i=[[] for _ in range(m)] i[0]=[1] c=1 for i_1 in i: for i_2 in i_1: a=[] for k in l: if i_2 in k: a.append(k) else: continue for b in a: if b[0]==i_2: ...
s550172469
p03805
u098420017
1565844305
Python
Python (3.4.3)
py
Runtime Error
17
2940
3
 
s190958045
p03805
u229959388
1565807938
Python
Python (3.4.3)
py
Runtime Error
18
3064
651
def main(): n, m = map(int, input().split()) mat = [[0]*n for i in range(n)] l = [list(map(int, input().split())) for _ in range(m)] for i in range(n): mat[l[i][0]-1][l[i][1]-1] = 1 mat[l[i][1]-1][l[i][0]-1] = 1 ver = [i for i in range(n)] cnt = 0 def dfc(now, moved)...
s813083127
p03805
u229959388
1565807871
Python
Python (3.4.3)
py
Runtime Error
21
3188
1255
def main(): n, m = map(int, input().split()) mat = [[0]*n for i in range(n)] l = [list(map(int, input().split())) for _ in range(m)] for i in range(n): mat[l[i][0]-1][l[i][1]-1] = 1 mat[l[i][1]-1][l[i][0]-1] = 1 ver = [i for i in range(n)] cnt = 0 def dfc(now, move...
s636409879
p03805
u889344512
1565738145
Python
PyPy3 (2.4.0)
py
Runtime Error
182
38256
410
n, m = map(int,input().split()) ab = [[0 for i in range(n)] for j in range(n)] for i in range(m): ai,bi = map(int,input().split()) ab[ai-1][bi-1] = 1 ab[bi-1][ai-1] = 1 count = 0 def dfs(x,v): l = v.copy() l.append(x) if len(l)==n: global count count += 1 for i in range(n):...
s014879902
p03805
u408760403
1565644823
Python
Python (3.4.3)
py
Runtime Error
18
3064
569
N,M=map(int,input().split()) tbl=[[0]*(N+1) for _ in range(N+1)] for i in range(M): a,b=map(int,input().split()) tbl[a][b]=1 tbl[b][a]=1 # グラフの行列を用いた表現 def dfs(s,visited): if len(visited)==N: return 1 ans=0 for i in range(1,N+1): if i==s: continue #自己閉路は関係ない。 if tbl[s][i]==1 an...
s927079802
p03805
u492447501
1565521382
Python
Python (3.4.3)
py
Runtime Error
22
3444
1041
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i != ...
s402055470
p03805
u492447501
1565521115
Python
Python (3.4.3)
py
Runtime Error
23
3444
1041
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i != ...
s539978726
p03805
u492447501
1565520935
Python
Python (3.4.3)
py
Runtime Error
22
3444
1053
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True print(cur_node) print(pre_node)...
s166825589
p03805
u492447501
1565518807
Python
Python (3.4.3)
py
Runtime Error
22
3444
1029
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N-1: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i ...
s128626213
p03805
u492447501
1565518647
Python
Python (3.4.3)
py
Runtime Error
22
3444
1031
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N-1 or cur_node <= 0 or cur_node >= N-1: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if ...
s967351072
p03805
u492447501
1565518509
Python
Python (3.4.3)
py
Runtime Error
39
3956
1033
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N-1 or cur_node <= 0 or cur_node >= N-1: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if ...
s413207918
p03805
u492447501
1565518466
Python
Python (3.4.3)
py
Runtime Error
22
3444
1031
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N-1: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i ...
s832400804
p03805
u492447501
1565518403
Python
Python (3.4.3)
py
Runtime Error
22
3444
1016
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N-1: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i ...
s868576848
p03805
u492447501
1565518109
Python
Python (3.4.3)
py
Runtime Error
22
3444
1015
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N or cur_node <= 0 or cur_node >= N: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True for i in range(N): if i !=...
s188742968
p03805
u492447501
1565516676
Python
Python (3.4.3)
py
Runtime Error
23
3444
1016
import copy def dfs(cur_node, pre_node, Node_num, map, l): #全てのノードを見たとき if Node_num == N-1 or cur_node <= 0 or cur_node >= N: return elif l[pre_node][cur_node]==0: #飛んだ先が、Trueの時 return elif map[cur_node]==True: return map[cur_node]=True dfs(cur_node+1, cur_node, Node_...
s714889381
p03805
u814986259
1565459369
Python
Python (3.4.3)
py
Runtime Error
39
3064
575
N,M=map(int,input().split()) ab=[[0]*8]*8 a=[0]*M b=[0]*M reached=[0]*M for i in range(M): a[i],b[i]=map(int,input().split()) ab[a[i]-1][b[i]-1]=1 ab[b[i]-1][a[i]-1]=1 def rootCount(pos,N,reached): count=0 prev=0 finish=1 for i in range(N): if reached[i] == 0: finish=0 if finish==1: ...
s460376125
p03805
u814986259
1565459162
Python
Python (3.4.3)
py
Runtime Error
39
3064
573
N,M=map(int,input().split()) ab=[[0]*8]*8 a=[0]*M b=[0]*M reached=[0]*M for i in range(M): a[i],b[i]=map(int,input().split()) ab[a[i]-1][b[i]-1]=1 ab[b[i]-1][a[i]-1]=1 def rootCount(pos,N,reached): count=0 prev=0 finish=1 for i in range(N): if reached[i] == 0: finish=0 if finish==1: ...
s585595695
p03805
u814986259
1565453295
Python
Python (3.4.3)
py
Runtime Error
34
3064
457
N,M=map(int,input().split()) ab=[[0]*M]*M a=[0]*M b=[0]*M reached=[0]*M for i in range(M): a[i],b[i]=map(int,input().split()) ab[a[i]][b[i]]=1 ab[b[i]][a[i]]=1 def rootCount(pos,N,reached): count=0 prev=0 for i in range(N): if ab[pos][i]==0: continue if reached[i]==1: continue ...
s650300560
p03805
u037430802
1564806796
Python
Python (3.4.3)
py
Runtime Error
24
3064
615
N, M = map(int, input().split()) if M == 0: print(0) exit() es = [[] for i in range(M)] for i in range(M): a, b = map(int, input().split()) a,b = a-1, b-1 es[a].append(b) es[b].append(a) def dfs(v, visited, es, cnt): #print("--------------") #print((v, visited, cnt)) if cnt == N...
s521375129
p03805
u037430802
1564806707
Python
Python (3.4.3)
py
Runtime Error
23
3064
579
N, M = map(int, input().split()) es = [[] for i in range(M)] for i in range(M): a, b = map(int, input().split()) a,b = a-1, b-1 es[a].append(b) es[b].append(a) def dfs(v, visited, es, cnt): #print("--------------") #print((v, visited, cnt)) if cnt == N-1: return 1 ret = 0 ...
s577735839
p03805
u214434454
1563851126
Python
Python (3.4.3)
py
Runtime Error
18
3064
703
n, m = map(int,input().split()) lis = [0 for i in range(m)] for i in range(m): lis[i] = list(map(int,input().split())) seen = [] count = 0 visited = [0 for i in range(m)] r = 0 def route(x=1): for i in range(m): if lis[i][0] == x and visited[i] == 0: visited[i] = 1 r += 1 ...
s938787218
p03805
u214434454
1563850751
Python
Python (3.4.3)
py
Runtime Error
17
3064
648
n, m = map(int,input().split()) lis = [0 for i in range(m)] for i in range(m): lis[i] = list(map(int,input().split())) seen = [] count = 0 def route(x=1): for i in range(m): if lis[i][0] == x and visited[i] == 0: visited[i] = 1 route(lis[i][1]) visited[i] = 0 ...
s191065026
p03805
u872887731
1563343234
Python
Python (3.4.3)
py
Runtime Error
17
3064
527
def dfs(v,N,visit_list): all_visit = True for i in range(N): if visit_list[i] == False: all_visit = False if all_visit: return 1 ret = 0 for k in range(N): if Graph[v][k] == False: continue if visit_list[k] : continue ...
s283573263
p03805
u872887731
1563343109
Python
Python (3.4.3)
py
Runtime Error
17
3064
735
N,M = map(int,input().split()) pat = [[int(i) for i in input().split()] for _ in range(M)] Graph = [[0 for i in range(N)] for _ in range(N)] for i,j in pat: Graph[i-1][j-1] = 1 Graph[j-1][i-1] = 1 def dfs(v,N=N,visit_list): all_visit = True for i in range(N): if visit_list[i] == False: ...
s943777224
p03805
u828766688
1562870888
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38384
479
N,M = map(int,input().split()) lis = [] path = ["1"] for i in range(M): a,b = map(int,input().split()) lis.append([a,b]) for i in range(N-1): i += 1 npath = [] for p in path: for j in lis: if j[0] == int(p[-1]) and str(j[1]) not in p: npath.append(p + s...
s345841670
p03805
u828766688
1562870790
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38672
478
N,M = map(int,input().split()) lis = [] path = ["1"] for i in range(M): a,b = map(int,input().split()) lis.append([a,b]) for i in range(N-1): i += 1 npath = [] for p in path: for j in lis: if j[0] == int(p[-1]) and str(j[1]) not in p: npath.append(p + s...
s314154158
p03805
u532966492
1562813049
Python
Python (3.4.3)
py
Runtime Error
32
8052
447
N,M=map(int,input().split()) inp=[list(map(int,input().split())) for _ in range(N)] g=[[] for _ in range(N)] [g[a-1].append(b-1) for a,b in inp] [g[b-1].append(a-1) for a,b in inp] from itertools import permutations seq=[i for i in range(N)] test=list(permutations(seq)) cnt=0 for t in test: if t[0]==0: fo...
s114638753
p03805
u532966492
1562812922
Python
Python (3.4.3)
py
Runtime Error
33
8052
428
N,M=map(int,input().split()) inp=[list(map(int,input().split())) for _ in range(N)] g=[[] for _ in range(N)] [g[a-1].append(b-1) for a,b in inp] [g[b-1].append(a-1) for a,b in inp] from itertools import permutations seq=[i for i in range(N)] test=list(permutations(seq)) cnt=0 for t in test: if t[0]==0: for...
s994650153
p03805
u007550226
1562016425
Python
Python (3.4.3)
py
Runtime Error
33
3064
524
N,M = map(int,input().split()) if M == 0: print(0) else: l = [[0 for _ in range(M)] for _ in range(M)] for _ in range(M): a,b = map(int,input().split()) l[a-1][b-1] = 1 l[b-1][a-1] = 1 g = 0 def dfs(a,route): global g if len(route) == N:g += 1 else: ...
s016153846
p03805
u007550226
1562015744
Python
Python (3.4.3)
py
Runtime Error
34
3064
409
N,M = map(int,input().split()) l = [[0 for _ in range(M)] for _ in range(M)] for _ in range(M): a,b = map(int,input().split()) l[a-1][b-1] = 1 l[b-1][a-1] = 1 g = 0 def dfs(a,route): global g if len(route) == N:g += 1 else: for i in range(N): if a == i:pass else: ...
s827545259
p03805
u711539583
1561727353
Python
Python (3.4.3)
py
Runtime Error
17
3064
373
n, m = map(int, input().split()) d = {i+1 : [] for i in range(n)} for _ in range(n): a, b = map(int, input().split()) d[a].append(b) d[b].append(a) ans = 0 def go(c, rem): global ans if not len(rem): ans += 1 return for cand in d[c]: if cand in rem: i = rem.index(cand) go(cand, rem[:...
s812457837
p03805
u651803486
1561681410
Python
Python (3.4.3)
py
Runtime Error
18
3064
646
N, M = map(int, input().split()) to = [[] for _ in range(N)] visited = [False] * N def dfs(v): n_visited = sum([1 if v else 0 for v in visited]) if n_visited == N: return 1 ret = 0 for u in to[v]: if not visited[u]: visited[u] = True ret += dfs(u) ...
s378159838
p03805
u777923818
1561434613
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38256
366
def inpl(): return list(map(int, input().split())) N, M = inpl() G = [[0]*(N+1) for _ in range(N+1)] for _ in range(M): a, b = inpl() G[a][b] = 1 G[b][a] = 1 ans = 0 for X in permutations(range(2, N+1)): a = 1 for i in range(N-1): b = X[i] if G[a][b] == 0: break ...
s941076493
p03805
u247554097
1561389087
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38512
662
# 全域木?っていうんだっけ?でもコストは関係ないか # 適当に隣接リストでもってしてDFSする N, M = map(int, input().split()) Neighbor_list = [[] for _ in range(n)] for _ in range(M): s, t = map(int, input().split()) Neighbor_list[s-1].append(t-1) Neighbor_list[t-1].append(s-1) def dfs(cur, path): if len(path) == N: return 1 else: ...
s470218041
p03805
u256031597
1561083456
Python
Python (3.4.3)
py
Runtime Error
28
3064
468
N, M = map(int, input().split()) gr = set() for i in range(N): a, b = map(int, input().split()) gr |= {(a-1,b-1),(b-1,a-1)} from itertools import permutations ans = 0 for p in permutations(range(N)): if p[0]==0: cnt = 0 cntp = 0 for i in range(N-1): cnt += 1 ...
s798418713
p03805
u102461423
1560917620
Python
Python (3.4.3)
py
Runtime Error
27
3064
380
import itertools N,M = map(int,input().split()) edges = set() for _ in range(N): a,b = map(int,input().split()) edges.add((a,b)) edges.add((b,a)) answer = 0 for p in itertools.permutations(range(1,N+1)): if p[0] != 1: continue bl = True for i in range(N-1): if (p[i], p[i+1]) not in edges: bl...
s425996575
p03805
u580904613
1560822702
Python
Python (3.4.3)
py
Runtime Error
17
3064
491
n, m = map(int, input().split()) adj_matrix = [[0] * n for _ in range(N)] for i in range(m): a, b = map(int, input().split()) adj_matrix[a-1][b-1] = 1 adj_matrix[b-1][a-1] = 1 def dfs(v, used): if not False in used: return 1 ans = 0 for i in range(n): if not adj_matrix[v][i]: continue ...
s840061153
p03805
u672494157
1560632129
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
1039
import sys from collections import deque sys.setrecursionlimit(4100000) def inputs(num_of_input): ins = [input() for i in range(num_of_input)] return ins def solve(N, M, inputs): relations = {} visited_all = (2 ** N) - 1 for i in range(1, N + 1): relations[i] = [] for i in inputs: ...
s026617342
p03805
u977193988
1560547222
Python
Python (3.4.3)
py
Runtime Error
26
3064
519
import sys sys.setrecursionlimit(10000) n,m=map(int,input().split()) bra=[set() for _ in range(m)] for i in range(m): a,b=map(int,input().split()) bra[a-1].add(b-1) bra[b-1].add(a-1) visit=[1]+[0]*(n-1) #print(bra) cnt=[] def dfs(a,visit): if visit==[1]*n: cnt.append(1) return else...
s638746561
p03805
u977193988
1560545787
Python
Python (3.4.3)
py
Runtime Error
27
3064
519
import sys sys.setrecursionlimit(10000) n,m=map(int,input().split()) bra=[set() for _ in range(m)] for i in range(m): a,b=map(int,input().split()) bra[a-1].add(b-1) bra[b-1].add(a-1) visit=[1]+[0]*(n-1) #print(bra) cnt=[] def dfs(a,visit): if visit==[1]*n: cnt.append(1) return else...
s722503739
p03805
u977193988
1560545660
Python
Python (3.4.3)
py
Runtime Error
26
3064
494
n,m=map(int,input().split()) bra=[set() for _ in range(m)] for i in range(m): a,b=map(int,input().split()) bra[a-1].add(b-1) bra[b-1].add(a-1) visit=[1]+[0]*(n-1) #print(bra) cnt=[] def dfs(a,visit): if visit==[1]*n: cnt.append(1) return else: for e in bra[a]: i...
s260524089
p03805
u416773418
1560391329
Python
Python (3.4.3)
py
Runtime Error
2209
1707424
498
import itertools n,m=map(int,input().split()) lst=[] for i in range(m): lst+=[list(map(int,input().split()))] pair=[[0]*n for i in range(n)] for i,j in lst: pair[i-1][j-1]=1 pair[j-1][i-1]=1 def keiro(a): count=0 for i in range(n-1): if pair[a[i]-1][a[i+1]-1]==0: break e...
s975307603
p03805
u620219777
1559880472
Python
Python (3.4.3)
py
Runtime Error
37
3064
682
N, M = map(int, input().split()) graph = [] visited = [] def dfs(v, N, visited): all_visited = True for i in range(N): if(visited[i]==False): all_visited = False if (all_visited): return 1 ret = 0 for i in range(N): if(graph[v][i]==False): continue if(vis...
s048574096
p03805
u879870653
1559834386
Python
Python (3.4.3)
py
Runtime Error
17
3064
556
N,M = map(int,input().split()) L = [[] for i in range(N)] for i in range(M) : a,b = map(int,input().split()) a -= 1 b -= 1 L[a].append(b) L[b].append(a) P = permutations([0] + [i for i in range(1,N)]) ans = 0 for perm in P : visited = [0 for i in range(N)] visited[0] = 1 for i ...
s668172787
p03805
u838644735
1559797070
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38384
631
l = input().split() N = int(l[0]) M = int(l[1]) A = [] B = [] C = [[] for i in range(N)] for i in range(M): l = input().split() a = int(l[0]) - 1 b = int(l[1]) - 1 A.append(a) B.append(b) C[a].append(b) C[b].append(a) # print(N, M, A, B, C) def visit(cur, ans, visited): # print('cur=...
s923784408
p03805
u969190727
1558749589
Python
Python (3.4.3)
py
Runtime Error
44
3064
439
import itertools n,m=map(int,input().split()) A=[] for i in range(n): a,b=map(int,input().split()) A.append([a,b]) N=[int(i+2) for i in range(n-1)] def f(list,n): path=0 if [1,list[0]] in A: path+=1 for i in range(1,n-1): if [list[i],list[i-1]] in A or [list[i-1],list[i]] in A: path+=1 if path...
s796380501
p03805
u039360403
1558432424
Python
Python (3.4.3)
py
Runtime Error
39
8052
306
import itertools N,M=map(int,input().split()) ab=list(list(map(int,input().split())) for _ in range(N)) l=list(l for l in range(1,N+1)) numlist=list(itertools.permutations(l)) ans=0 for I in numlist: x=0 if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)): ans+=1 print(ans)
s885173146
p03805
u500944229
1558246317
Python
Python (3.4.3)
py
Runtime Error
18
3064
494
n,m = map(int,input()) path = [map(int,input()) for x in range(m)] table = [[] for x in range(n)] for x in path: table[int(x[0])-1].append(int(x[1])-1) table[int(x[1])-1].append(int(x[0])-1) import itertools count = 0 for z in itertools.permutations(range(0,n)): if z[0] == 0: print(z) ...
s328568564
p03805
u785578220
1558129049
Python
Python (3.4.3)
py
Runtime Error
17
2940
271
from itertools import permutations n,m=map(int,input().split()) path=set() for _ in range(m): u,v=map(int,input().split()) path|={(u-1,v-1),(v-1,u-1)} s = 0 for i in permutations(range(n)): s+=(all((h,j) in path for h,j in zip(i[1:],i))) if i[0] ==0 print(s)
s339701210
p03805
u785578220
1558128313
Python
Python (3.4.3)
py
Runtime Error
18
3060
292
######### #thiking Face from itertools import permutations n,m=map(int,input().split()) path=set() for _ in range(m): u,v=map(int,input().split()) path|={(u-1,v-1),(v-1,u-1)} print(sum(all((u,v) in es for u,v in zip(p,p[1:])) for p in permutations(range(n)) if p[0]==0))
s403240898
p03805
u785578220
1558128153
Python
Python (3.4.3)
py
Runtime Error
18
3060
296
########### ######### #thiking Face from itertools import permutations n,m=map(int,input().split()) path=set() for _ in range(m): u,v=map(int,input().split()) path|={(u-1,v-1),(v-1,u-1)} print(sum(all((u,v) in es for u,v in zip([0]+p,p)) for p in permutations(range(1,n))))
s529487614
p03805
u172386990
1557897336
Python
Python (3.4.3)
py
Runtime Error
251
17124
1060
import numpy as np N, M = map(int, input().split()) Adj_matrix = np.zeros((N, N)) for _ in range(N): a, b = map(int, input().split()) Adj_matrix[a - 1, b - 1] += 1 Adj_matrix[b - 1, a - 1] += 1 def initialize(): explored_list = np.zeros((N, 1)) return explored_list def is_move(vertex, explo...
s226863621
p03805
u392220578
1557031214
Python
Python (3.4.3)
py
Runtime Error
17
3060
298
import itertools n, m = [int(x) for x in input().split()] edges = set(tuple(int(x) for x in input().split()) for _ in range(m)) print(sum(1 if all(p in edges or tuple(reversed(p)) in edges for p in [(1, path[0]), *zip(path, path[1:])]) else 0 for path in itertools.permutations(range(2, n + 1))))