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
s329791591
p03805
u119655368
1583890997
Python
Python (3.4.3)
py
Runtime Error
18
3064
524
n, m = map(int, input().split()) l = [list(map(int, input().split())) for i in range(m)] r = [[] for i in range(n + 1)] ans = 0 for i in range(m): r[l[i][0]].append(l[i][1]) r[l[i][1]].append(l[i][0]) p = [] for i in range(n): p.append(i + 1) p = list(itertools.permutations(p)) for i in range(len(p)): c...
s271765711
p03805
u686036872
1583737313
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38256
498
import sys sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限 N, M = map(int, input().split()) A = [[0]* N for _ in range(N)] for i in range(M): a, b = map(int, input().split()) A[a-1][b] = 1 A[b-1][a] = 1 visited=[0]*N ans = 0 def DFS(x): if not 0 in visited: return 1 for i in range(N): if n...
s938258035
p03805
u686036872
1583737134
Python
PyPy3 (2.4.0)
py
Runtime Error
184
40432
481
import sys sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限 N, M = map(int, input().split()) A = [0]*(N+1) for i in range(M): a, b = map(int, input().split()) A[a-1][b] = 1 A[b-1][a] = 1 visited=[0]*N ans = 0 def DFS(x): if not 0 in visited: return 1 for i in range(N): if not 1 in A[x][i]: ...
s244671464
p03805
u686036872
1583735593
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38384
431
import sys sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限 N, M = map(int, input().split()) A = [0]*(N+1) for i in range(M): a, b = map(int, input().split()) A[a].append([b]) A[b].append([a]) visited=[1]+[0]*N ans = 0 def DFS(x): if visited[x] == 1: return if sum(visited) == N: ans += 1 ...
s025268513
p03805
u686036872
1583735227
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38640
413
import sys sys.setrecursionlimit(10**7) #再帰関数の呼び出し制限 N, M = map(int, input().split()) A = [0]*(N+1) for i in range(M): a, b = map(int, input().split()) A[a].append([b]) A[b].append([a]) visited=[1]+[0]*N ans = 0 def DFS(x): if visited[x] == 1: return if sum(visited) == N: ans += 1 ...
s850390693
p03805
u112317104
1583347841
Python
Python (3.4.3)
py
Runtime Error
21
3316
601
from collections import deque def dfs(v, P, visited, N): if len(list(filter(lambda x: x == True, visited))) == N: return 1 c = 0 for i in P[v]: if visited[i]: continue visited[i] = True c += dfs(i, P, visited, N) visited[i] = False return c def resolve(): ...
s482971956
p03805
u112317104
1583347721
Python
Python (3.4.3)
py
Runtime Error
21
3316
601
from collections import deque def dfs(v, P, visited, N): if len(list(filter(lambda x: x == True, visited))) == N: return 1 c = 0 for i in P[v]: if visited[i]: continue visited[i] = True c += dfs(i, P, visited, N) visited[i] = False return c def resolve(): ...
s344159890
p03805
u995062424
1583283817
Python
Python (3.4.3)
py
Runtime Error
26
3064
406
N, M = map(int, input().split()) dict = {i+1:[] for i in range(M)} for _ in range(M): a, b = map(int, input().split()) dict[a].append(b) dict[b].append(a) def DFS(visited, sight, cnt): if(len(visited) == N): return cnt+1 for num in dict[sight]: if num in visited: con...
s471541270
p03805
u593934357
1583274316
Python
PyPy3 (2.4.0)
py
Runtime Error
300
66776
1061
import sys from math import * from collections import deque, Counter, defaultdict from fractions import gcd from itertools import permutations input = lambda: sys.stdin.readline().rstrip() def eprint(s): sys.stderr.write('DEBUG: {}'.format(s)) return def main(): n,m = map(int, input().split()) graph ...
s320526347
p03805
u593934357
1583274249
Python
Python (3.4.3)
py
Runtime Error
46
5072
1061
import sys from math import * from collections import deque, Counter, defaultdict from fractions import gcd from itertools import permutations input = lambda: sys.stdin.readline().rstrip() def eprint(s): sys.stderr.write('DEBUG: {}'.format(s)) return def main(): n,m = map(int, input().split()) graph ...
s614464833
p03805
u940139461
1583185120
Python
PyPy3 (2.4.0)
py
Runtime Error
348
62936
845
n, m = map(int, input().split()) graph = [[] for _ in range(m + 1)] for _ in range(m): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) def my_permutations(nums, t, path): if len(nums) == 0: path.append(t) return for i in range(len(nums)): my_permutatio...
s889864554
p03805
u139112865
1583052666
Python
Python (3.4.3)
py
Runtime Error
17
3064
367
#054_C from itertools import permutations n,m=map(int,input().split()) edges=[[False for _ in range(n)] for _ in range(n)] for _ in range(m): a,b=map(int,input().split()) a,b=a-1,b-1 edges[a][b]=edges[b][sa]=True ans=0 for l in permutations(range(1,n),n-1): l=[0]+list(l) if all(edges[l[i]][l[i+1]] ...
s503713212
p03805
u863442865
1583005630
Python
Python (3.4.3)
py
Runtime Error
18
3060
884
res = 0 def main(): import sys #input = sys.stdin.readline sys.setrecursionlimit(10000000) from collections import Counter, deque #from collections import defaultdict from itertools import combinations #from itertools import accumulate, product, permutations from math import floor, ceil ...
s729861026
p03805
u729535891
1582997719
Python
Python (3.4.3)
py
Runtime Error
2230
1724704
496
from itertools import permutations n, m = map(int, input().split()) LST = [[0]*2 for _ in range(m)] for i in range(m): a, b = map(int, input().split()) LST[i][0] = a - 1 LST[i][1] = b - 1 roots = list(permutations(range(m))) ans = 0 for root in roots: tmp = 0 if root[0] != 0: continue ...
s848180544
p03805
u729535891
1582996417
Python
Python (3.4.3)
py
Runtime Error
2215
1725472
478
from itertools import permutations n, m = map(int, input().split()) LST = [[0]*2 for _ in range(m)] for i in range(m): a, b = map(int, input().split()) LST[i][0] = a - 1 LST[i][1] = b - 1 roots = list(permutations(range(m))) ans = 0 for root in roots: tmp = 0 if root[0] != 0: continue f...
s263186626
p03805
u995062424
1582987088
Python
Python (3.4.3)
py
Runtime Error
17
3064
529
N, M = map(int, input().split()) graph ={i+1:[] for i in range(N)} for _ in range(N): a, b = map(int, input().split()) graph[a].append(b) graph[b].append(a) def DFS(graph, start, end): stack = [start] visited = [] cnt = 0 while stack: label = stack.pop(0) if label == end...
s471017884
p03805
u746419473
1582843600
Python
Python (3.4.3)
py
Runtime Error
33
3064
453
import itertools n, m = map(int, input().split()) am = [[False]*m for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) am[a-1][b-1] = True am[b-1][a-1] = True ans = 0 for p in itertools.permutations(list(range(n)), n): if p[0] != 0: continue isok = True for i in ran...
s422066076
p03805
u577138895
1582775970
Python
PyPy3 (2.4.0)
py
Runtime Error
187
40048
348
N, M = map(int, input().split()) V = [[] for _ in range(M)] for _ in range(M): a, b = map(int, input().split()) V[a - 1].append(b - 1) V[b - 1].append(a - 1) ctr = 0 def dfs(a, lst): lst.append(a) global ctr if len(lst) == N: ctr += 1 return 0 for v in V[a]: if v in lst: continue return dfs(v, ls...
s148110614
p03805
u944643608
1582754475
Python
Python (3.4.3)
py
Runtime Error
18
3064
525
#深さ優先探索 N, M = map(int,input().split()) graph = [[] for j in range(N)] for i in range(M): a, b = map(int,input().split()) graph[a-1].append(b-1) graph[b-1].append(a-1) judge = [False]*N def dfs(v,judge):#vは今いる場所 if all(judge): return 1 res = 0 for nv in graph(v):#vと隣り合っている場所 if judge[nv] == True:#す...
s429755951
p03805
u693378622
1582539164
Python
Python (3.4.3)
py
Runtime Error
17
2940
415
N,M = gets.split.map(&:to_i) g = Array.new(N){Array.new(N)} M.times do |i| a,b = gets.split.map(&:to_i).sort.reverse a -= 1 b -= 1 g[a][b] = g[b][a] = 1 end pattern = [*1...N].permutation.to_a.map{ |k| [0] + k } ans = 0 pattern.each do |p| f = true (1...N).each do |i| p [p[i-1], p[i]] i...
s763951923
p03805
u112317104
1582345503
Python
Python (3.4.3)
py
Runtime Error
17
3064
485
N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] visited = [False] * N visited[0] = True d = {} for a, b in A: d.setdefault(b-1, []).append(a-1) d.setdefault(a-1, []).append(b-1) l = sorted(d.items()) def dfs(v, seen): if False not in seen: return 1 c = 0 ...
s882828688
p03805
u112317104
1582264681
Python
Python (3.4.3)
py
Runtime Error
17
3064
595
N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] visited = [False] * N visited[0] = True d = {} for a, b in A: d.setdefault(a, []).append(b) d.setdefault(b, []).append(a) l = sorted(d.items()) # print(d) def dfs(v, c): if visited[v-1]: return 0 visited[v-1] = T...
s218919649
p03805
u301624971
1582086294
Python
Python (3.4.3)
py
Runtime Error
40
3064
847
def df_search(searchNode,node,sss,i): global cnt ss=sss+1 sn=searchNode sn.append(i) if(hantei==sorted(sn)): if(ans==[]): cnt+=1 ans.append(searchNode) else: for an in ans[:]: if(an != searchNode): cnt+=1 ...
s757295658
p03805
u103902792
1581826199
Python
Python (3.4.3)
py
Runtime Error
20
3064
323
n,m = map(int,input().split()) graph = {i+1:[] for i in range(n)} for _ in range(m): a,b = map(int,input(),split()) graph[a].append(b) graph[b].append(a) count = 0 def func(path,p): if len(path) == n: count += 1 return for i in graph[p]: if i in path: continue func(path+[i],i) print(cou...
s918936181
p03805
u090266528
1581198463
Python
PyPy3 (2.4.0)
py
Runtime Error
196
40816
502
N, M = list(map(int, input().split())) ab = {i:[] for i in range(N)} for _ in range(M): a, b = list(map(int, input().split())) ab[a-1].append(b-1) ab[b-1].append(a-1) cand = [[0]+[one] for one in ab[0]] while len(cand)>0: tmp_cand = [] for c in cand: last = c[-1] n = [] ...
s614458282
p03805
u686036872
1580604913
Python
Python (3.4.3)
py
Runtime Error
17
3064
436
N, M = map(int, input().split()) matrix=[[0]*N for i in range(N)] for i in range(M): a, b = map(int, input().split()) matrix[a-1][b-1]=1 matrix[b-1][a-1]=1 import itertools count=0 for i in itertools.permulations(range(N)): if i[0]==0: for j in range(N-1): result=1 resul...
s966033419
p03805
u686036872
1580604852
Python
Python (3.4.3)
py
Runtime Error
17
3064
430
N, M = map(int, input().split()) matrix=[[0]*N for i in range(N)] for i in range(M): a, b = map(int, input().split()) matrix[a-1][b-1]=1 matrix[b-1][a-1]=1 import itertools count=0 for i in itertools.permulations(range(N)): if i[0]==0: for j in range(N-1): result=1 resul...
s593870205
p03805
u686036872
1580604763
Python
Python (3.4.3)
py
Runtime Error
17
3064
458
N, M = map(int, input().split()) matrix=[[0]*N for i in range(N)] for i in range(M): a, b = map(int, input().split()) matrix[a-1][b-1]=1 matrix[b-1][a-1]=1 import itertools count=0 result=1 for i in itertools.permulations(range(N)): if i==0: for j in range(N-1): result*=matrix[i[j]]...
s678594627
p03805
u686036872
1580604579
Python
Python (3.4.3)
py
Runtime Error
17
3064
463
N, M = map(int, input().split()) matrix=[[0]*N for i in range(N)] for i in range(M): a, b = map(int, input().split()) matrix[a-1][b-1]=1 matrix[b-1][a-1]=1 import itertools count=0 result=1 for i in itertools.permulations(range(1, N+1)): if i==1: for j in range(N-1): result+=matrix[...
s105446178
p03805
u686036872
1580604521
Python
Python (3.4.3)
py
Runtime Error
17
3064
436
N, M = map(int, input().split()) matrix=[[0]*N for i in range(N)] for i in range(M): a, b = map(int, input().split()) matrix[a-1][b-1]=1 matrix[b-1][a-1]=1 import itertools count=0 result=1 for i in itertools.permulations(range(1, N+1)): if i==1: for j in range(): result+=matrix[i[j...
s537490067
p03805
u740284863
1580593629
Python
Python (3.4.3)
py
Runtime Error
24
3064
481
def dfs(v,been): if len(been) == n: ans.append(1) #print(been) return for i in graph[v]: if i in been: pass else: been.add(i) dfs(i,been) been.remove(i) return n,m = map(int,input().split()) graph = [[] for _ in range(m...
s413331363
p03805
u624689667
1580335161
Python
PyPy3 (2.4.0)
py
Runtime Error
181
40048
464
from itertools import permutations N, M = [int(i) for i in input().split()] adjacent = [[0] * N for _ in range(N)] for _ in range(N): a, b = [int(i) for i in input().split()] adjacent[a - 1][b - 1] = 1 adjacent[b - 1][a - 1] = 1 ans = 0 for p in permutations(range(N), r=N): if p[0] != 0: conti...
s136277475
p03805
u624689667
1580334973
Python
PyPy3 (2.4.0)
py
Runtime Error
195
39280
523
from itertools import permutations N, M = [int(i) for i in input().split()] adjacent = [[0] * N for _ in range(N)] for _ in range(N): a, b = [int(i) for i in input().split()] adjacent[a - 1][b - 1] = 1 adjacent[b - 1][a - 1] = 1 ans = 0 for p in permutations(range(1, N), r=N-1): start, end = 0, p[0] ...
s594411526
p03805
u853819426
1580326391
Python
Python (3.4.3)
py
Runtime Error
17
3064
422
def search(node, searched, goal): if searched == goal: return 1 v = 0 for nei in edges[node]: if searched & (1 << nei): continue v += search(nei, searched | (1<<nei), goal) return v n, m = map(int, input().split()) edges = [[] for _ in range(n)] for i in range(n): a, b = map(lambda x: i...
s241158997
p03805
u191394596
1580303872
Python
Python (3.4.3)
py
Runtime Error
30
3572
510
from itertools import permutations, tee N, M = map(int, input().split()) edges = set() for _ in range(N): a, b = map(int, input().split()) edges.add((a, b)) def each_cons(iterable): a, b = tee(iterable) next(b, None) return zip(a, b) cases = list(permutations(range(2, N + 1), N - 1)) count = 0 def i...
s155510632
p03805
u169138653
1580252971
Python
Python (3.4.3)
py
Runtime Error
45
8052
494
from itertools import permutations n,m=map(int,input().split()) l=[list(map(int,input().split())) for i in range(m)] p=[i for i in range(1,n+1)] np=list(permutations(p)) edge=[[] for i in range(m)] for i in range(m): edge[l[i][0]-1].append(l[i][1]-1) edge[l[i][1]-1].append(l[i][0]-1) ans=0 for i in range(len(np)): ...
s611443281
p03805
u692515710
1580151443
Python
Python (3.4.3)
py
Runtime Error
28
4080
794
import sys import copy from queue import Queue sys.setrecursionlimit(1000000000) def dfs(start, paths, count): if count <= 1: return 1 indixies = findNodeIndex(start, paths) if len(indixies) == 0: return 0 count = 0 for i in indixies: nextNode = paths[i][1] if paths[i][...
s656932805
p03805
u798665594
1579679288
Python
Python (3.4.3)
py
Runtime Error
17
2940
835
#include <bits/stdc++.h> using namespace std; #define ll unsighned long int int n,m; int ans = 0; void solve(vector<vector<int> > v,vector<int> dist,int pos = 1,int k = 1){ //cout << ans << endl; if(k == n){ ans++; return ; } for(int i = 0; i < v[pos - 1].size(); ++i){ if(di...
s617375590
p03805
u798665594
1579678749
Python
Python (3.4.3)
py
Runtime Error
17
2940
833
#include <bits/stdc++.h> using namespace std; #define ll unsighned long int int n,m; int ans = 0; void solve(vector<vector<int> > v,vector<int> dist,int pos = 1,int k = 1){ //cout << ans << endl; if(k == n){ ans++; return ; } for(int i = 0; i < v[pos - 1].size(); ++i){ if(di...
s259099007
p03805
u798665594
1579678593
Python
Python (3.4.3)
py
Runtime Error
17
2940
824
#include <bits/stdc++.h> using namespace std; #define ll long int int n,m; int ans = 0; void solve(vector<vector<int> > v,vector<int> dist,int pos = 1,int k = 1){ //cout << ans << endl; if(k == n){ ans++; return ; } for(int i = 0; i < v[pos - 1].size(); ++i){ if(dist[v[pos -...
s430791065
p03805
u530786533
1579238236
Python
Python (3.4.3)
py
Runtime Error
17
3064
550
n, m = map(int, input().split()) edge = [[0] * n for _ in range(n)] for i in range(n): a, b = map(int, input().split()) edge[a-1][b-1] = 1 edge[b-1][a-1] = 1 # depth-first search def dfs(now, visited): if (False not in visited): return(1) ans = 0 for i in range(1, n+1): if (edge[now-1][i...
s833968015
p03805
u530786533
1579238090
Python
Python (3.4.3)
py
Runtime Error
18
3064
503
n, m = map(int, input().split()) edge = [[0] * n for _ in range(n)] for i in range(n): a, b = map(int, input().split()) edge[a-1][b-1] = 1 edge[b-1][a-1] = 1 def dfs(now, visited): if (False not in visited): return(1) ans = 0 for i in range(n): if (edge[now-1][i-1] == 1 and visited[i-1]...
s919008900
p03805
u404290207
1579155258
Python
PyPy3 (2.4.0)
py
Runtime Error
206
42352
713
import itertools n,m=map(int,input().split()) if n ==2: print(1) exit() arr=[[_] for _ in range(n)] for i in range(n): a,b=map(int,input().split()) arr[a-1].append(b-1) arr[b-1].append(a-1) for i in range(n): arr[i] = arr[i][1:] #print("arr",arr) route=list(itertools.permutations(range...
s040627089
p03805
u404290207
1579154919
Python
PyPy3 (2.4.0)
py
Runtime Error
184
40816
671
import itertools n,m=map(int,input().split()) if n ==2: print(1) exit() arr=[[_] for _ in range(n)] for i in range(n): a,b=map(int,input().split()) arr[a-1].append(b-1) arr[b-1].append(a-1) #print("arr",arr) route=list(itertools.permutations(range(1,n))) #print("route",route) ans=0 for i...
s706323058
p03805
u735008991
1578618703
Python
Python (3.4.3)
py
Runtime Error
17
2940
464
def dfs(v): for i in range(len(seen)): if !seen[i] and i != v: brea; else: res += 1 seen[i] = True for nv in G[v]: if seen[nv]: continue def(nv) seen[i] = False N, M = map(int, input().split()) G = dict([[i, [] for i in range(N)]]) fo...
s490573728
p03805
u439396449
1578277603
Python
Python (3.4.3)
py
Runtime Error
25
3064
569
import sys sys.setrecursionlimit(10**6) N, M = map(int, input().split()) graph = [set([]) for _ in range(M)] for _ in range(M): a, b = map(int, input().split()) graph[a - 1].add(b - 1) graph[b - 1].add(a - 1) def dfs(graph, visited, v): if all(visited): return 1 cnt = 0 for u in gra...
s341318308
p03805
u439396449
1578277058
Python
Python (3.4.3)
py
Runtime Error
25
3064
527
N, M = map(int, input().split()) graph = [set([]) for _ in range(M)] for _ in range(M): a, b = map(int, input().split()) graph[a - 1].add(b - 1) graph[b - 1].add(a - 1) def dfs(graph, visited, v): if all(visited): return 1 cnt = 0 for u in graph[v]: if visited[u]: ...
s402515345
p03805
u286623856
1578269219
Python
Python (3.4.3)
py
Runtime Error
40
3188
1448
import sys import math input = sys.stdin.readline used = [] connect = [] N = 0 M = 0 def main(): global used global connect global N global M sc = Scan() N, M = sc.intarr() a = [0] * M b = [0] * M for i in range(M): aa, bb = sc.intarr() a[i] = aa - 1 b[i] =...
s709505216
p03805
u745561510
1578247675
Python
PyPy3 (2.4.0)
py
Runtime Error
201
42972
597
import sys sys.setrecursionlimit(10 ** 6) N, M = map(int, input().split()) graph = [[] for i in range(M)] for i in range(M): v, e = map(int, input().split()) graph[v - 1].append(e - 1) graph[e - 1].append(v - 1) def dfs(v, seen, res): end = True for i in range(len(seen)): if seen[i] == Fa...
s202293242
p03805
u745561510
1578247549
Python
PyPy3 (2.4.0)
py
Runtime Error
233
44252
554
N, M = map(int, input().split()) graph = [[] for i in range(M)] for i in range(M): v, e = map(int, input().split()) graph[v - 1].append(e - 1) graph[e - 1].append(v - 1) def dfs(v, seen, res): end = True for i in range(len(seen)): if seen[i] == False and i != v: end = False ...
s666645392
p03805
u235376569
1578000359
Python
Python (3.4.3)
py
Runtime Error
18
3060
195
N,M=[int(x) for x in input().rstrip().split()] dp=[0 for i in range(N)] for i in range(N): a,b=[int(x) for x in input().rstrip().split()] dp[a-1]+=1 dp[b-1]+=1 dp.sort() print(dp[0])
s498937695
p03805
u875600867
1577992584
Python
Python (3.4.3)
py
Runtime Error
17
3064
1096
import sys # 再帰上限を引き上げる sys.setrecursionlimit(10**6) #### # DFS(深さ優先探索 count = 0 def dfs(graph, v, seen): #print(seen) # Falseがない、つまり頂点が1個しかない場合は、1を返す if not False in seen: global count count +=1 return # 頂点Vから行ける頂点を全探索 for i in graph[v]: # 行ける場所はTrueである。 ...
s794819189
p03805
u875600867
1577992480
Python
Python (3.4.3)
py
Runtime Error
17
3064
1096
import sys # 再帰上限を引き上げる sys.setrecursionlimit(10**6) #### # DFS(深さ優先探索 count = 0 def dfs(graph, v, seen): #print(seen) # Falseがない、つまり頂点が1個しかない場合は、1を返す if not False in seen: global count count +=1 return # 頂点Vから行ける頂点を全探索 for i in graph[v]: # 行ける場所はTrueである。 ...
s995768923
p03805
u962127640
1577931139
Python
Python (3.4.3)
py
Runtime Error
24
3064
470
N, M = list(map(int, input().split())) g = [[] for _ in range(N)] for i in range(N): a, b = list(map(int, input().split())) g[a-1].append(b-1) g[b-1].append(a-1) visited = [False for _ in range(N)] def dfs(v, visited): if all(visited): return 1 total = 0 for cv in g[v]: if not visited[cv]: ...
s027972400
p03805
u223646582
1577647154
Python
Python (3.4.3)
py
Runtime Error
17
3064
500
import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) G = {k: [] for k in range(N)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a-1].append(b-1) G[b-1].append(a-1) visited = [False]*N visited[0] = True def dfs(v): if all(visited): return 1 r = 0 ...
s628863229
p03805
u223646582
1577647094
Python
Python (3.4.3)
py
Runtime Error
19
3316
502
import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) G = {k: [] for k in range(N+1)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a-1].append(b-1) G[b-1].append(a-1) visited = [False]*N visited[0] = True def dfs(v): if all(visited): return 1 r = ...
s964418957
p03805
u223646582
1577647067
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38384
502
import sys sys.setrecursionlimit(1000000) N, M = map(int, input().split()) G = {k: [] for k in range(N+1)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a-1].append(b-1) G[b-1].append(a-1) visited = [False]*N visited[0] = True def dfs(v): if all(visited): return 1 r = ...
s983664071
p03805
u223646582
1577647021
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38640
468
N, M = map(int, input().split()) G = {k: [] for k in range(N+1)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a-1].append(b-1) G[b-1].append(a-1) visited = [False]*N visited[0] = True ans = 0 def dfs(v): if all(visited): return 1 r = 0 for nv in G[v]: if v...
s084050858
p03805
u223646582
1577646565
Python
Python (3.4.3)
py
Runtime Error
17
3064
470
N, M = map(int, input().split()) G = {k: [] for k in range(N+1)} for _ in range(N): a, b = map(int, input().split()) # 無向グラフ G[a-1].append(b-1) G[b-1].append(a-1) visited = [False]*N visited[0] = True def dfs(v): if all(visited): ans += 1 return for nv in G[i]: if visi...
s116918970
p03805
u708255304
1577496866
Python
Python (3.4.3)
py
Runtime Error
25
3064
475
import itertools N, M = map(int, input().split()) graph = [[False]*N for _ in range(M)] for _ in range(M): a, b = map(lambda x: int(x)-1, input().split()) graph[a][b] = True graph[b][a] = True ans = 0 for x in itertools.permutations(range(1, N)): # このxの順番で訪問できるか確かめる flag = True now = 0 f...
s009329329
p03805
u624689667
1577134864
Python
PyPy3 (2.4.0)
py
Runtime Error
203
42716
897
import sys sys.setrecursionlimit(10 ** 9) def dfs(v, n, graph, visited): all_visited = 1 for i in range(n): if visited[i] == 0: all_visited = 0 break if all_visited: return 1 n_paths = 0 for i in range(0, n): if not graph[v][i]: conti...
s285920431
p03805
u624689667
1577134749
Python
PyPy3 (2.4.0)
py
Runtime Error
206
42844
849
import sys sys.setrecursionlimit(10 ** 9) def dfs(v, n, graph, visited): all_visited = 1 for i in range(n): if visited[i] == 0: all_visited = 0 break if all_visited: return 1 n_paths = 0 for i in range(0, n): if not graph[v][i]: conti...
s147363631
p03805
u624689667
1577134672
Python
PyPy3 (2.4.0)
py
Runtime Error
204
42716
805
def dfs(v, n, graph, visited): all_visited = 1 for i in range(n): if visited[i] == 0: all_visited = 0 break if all_visited: return 1 n_paths = 0 for i in range(0, n): if not graph[v][i]: continue if visited[i]: conti...
s046567716
p03805
u181215519
1577063731
Python
Python (3.4.3)
py
Runtime Error
17
3064
690
N, M = map( int, input().split() ) ab = [ [ int(x) for x in input().split() ] for y in range(M) ] e = [ [ 0 for x in range(N) ] for y in range(N) ] flag = [ False for x in range(N) ] dp = [ 0 for x in range(N) ] #number of path from 1 to i for i in range(M) : e[ ab[i][0]-1 ][ ab[i][1]-1 ] = 1 e[ ab[i][1]-1 ][ a...
s342876081
p03805
u357949405
1576908774
Python
Python (3.4.3)
py
Runtime Error
20
3188
847
import itertools def main(): N, M = map(int, input().split()) VE = tuple(tuple(map(lambda x: int(x)-1, input().split())) for _ in range(M)) # print(VE) adj_mat = [[0 for _ in range(N)] for _ in range(M)] for ve in VE: adj_mat[ve[0]][ve[1]] = 1 adj_mat[ve[1]][ve[0]] = 1 # for ro...
s592043865
p03805
u694810977
1576874188
Python
Python (3.4.3)
py
Runtime Error
18
3064
558
n, m = map(int, input().split()) q = [] for i in range(m): a, b = map(int, input().split()) q.append({a, b}) cnt = 0 array = list(range(1, m+1)) while cnt != 10000: a = q.pop() for j in q: if len(j & a) != 0: # jとaに共通の値があるならば j |= a count = 0 break el...
s367121804
p03805
u694810977
1576874157
Python
Python (3.4.3)
py
Runtime Error
17
3064
558
n, m = map(int, input().split()) q = [] for i in range(m): a, b = map(int, input().split()) q.append({a, b}) cnt = 0 array = list(range(1, n+1)) while cnt != 10000: a = q.pop() for j in q: if len(j & a) != 0: # jとaに共通の値があるならば j |= a count = 0 break el...
s923578659
p03805
u694810977
1576874084
Python
Python (3.4.3)
py
Runtime Error
17
3064
530
n, m = map(int, input().split()) q = [] for i in range(m): a, b = map(int, input().split()) q.append({a, b}) cnt = 0 while cnt != 10000: a = q.pop() for j in q: if len(j & a) != 0: # jとaに共通の値があるならば j |= a count = 0 break else: # jとaに共通の値がなければ ...
s682923046
p03805
u694810977
1576874020
Python
Python (3.4.3)
py
Runtime Error
26
8052
617
import itertools n, m = map(int, input().split()) array = list(range(1, n + 1)) p = list(itertools.permutations(array)) q = [] for i in range(m): a, b = map(int, input().split()) q.append({a, b}) cnt = 0 while cnt != 10000: a = q.pop() for j in q: if len(j & a) != 0: # jとaに共通の値があるならば ...
s649118569
p03805
u706740637
1576745620
Python
Python (3.4.3)
py
Runtime Error
18
3064
720
import sys import itertools import math input = sys.stdin.readline #sys.setrecursionlimit(1e9) N,M = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(M)] graph=[[0]*8 for _ in range(8)] def dfs(v,visited): if sum(visited) == N: return 1 ret =0 for i in range(N): ...
s028134862
p03805
u706740637
1576745371
Python
Python (3.4.3)
py
Runtime Error
18
3064
720
import sys import itertools import math input = sys.stdin.readline #sys.setrecursionlimit(1e9) N,M = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(M)] graph=[[0]*N for _ in range(N)] def dfs(v,visited): if sum(visited) == N: return 1 ret =0 for i in range(N): ...
s586032548
p03805
u905582793
1576632842
Python
Python (3.4.3)
py
Runtime Error
18
3064
359
from itertools import permutations n,m=map(int,input().split()) side=[[] for _ in range(n+1)] for i in range(m): a,b=map(int,input().split()) side[a].append(b) side[b].append(a) route=[i for i in range(2,n+1)] ans=0 for x in permutations(route): x=(1)+x for i in range(n-1): if x[i+1] not in side[x[i]]: ...
s088753415
p03805
u560988566
1576438174
Python
Python (3.4.3)
py
Runtime Error
17
3064
730
n,m = map(int, input().split()) ls = [tuple(map(int, input().split())) for _ in range(m)] neighborls = [] for i in range(1,n+1): neighbors = [] for j in range(1, m+1): if (i,j) in ls or (j,i) in ls: neighbors.append(j) neighborls.append(neighbors) ans = 0 def main(): global ans ...
s959764831
p03805
u560988566
1576438006
Python
Python (3.4.3)
py
Runtime Error
18
3064
719
n,m = map(int, input().split()) ls = [tuple(map(int, input().split())) for _ in range(m)] neighborls = [] for i in range(1,n+1): neighbors = [] for j in range(1, m+1): if (i,j) in ls or (j,i) in ls: neighbors.append(j) neighborls.append(neighbors) ans = 0 def main(): visitedls = [1...
s494616119
p03805
u019637926
1575573093
Python
PyPy3 (2.4.0)
py
Runtime Error
182
38384
522
N, M = map(int, input().split()) Bs = [[] for _ in range(N + 1)] for _ in range(M): a, b = map(int, input().split()) Bs[a].append(b) Bs[b].append(a) import heapq st = [] heapq.heappush(st, (1, {1: True})) c = 0 while len(st) > 0: (node, log) = heapq.heappop(st) for b in Bs[node]: if b in lo...
s999598357
p03805
u633548583
1575145091
Python
Python (3.4.3)
py
Runtime Error
18
3064
342
import itertools n,m=map(int,input().split()) p=[[False]*n for i in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 p[a][b]=True p[b][a]=True ans=0 for i in itertools.permutations(range(1,n),n-1): list=[0]+[i] if all(p[list[j]][list[j+1]]==True for j in range(n)): ...
s147690204
p03805
u633548583
1575144718
Python
Python (3.4.3)
py
Runtime Error
26
3064
413
import itertools n,m=map(int,input().split()) p=[[False]*n for i in range(n)] ans=0 for i in range(n): a,b=map(int,input().split()) a-=1 b-=1 p[a][b]=True p[b][a]=True for i in itertools.permutations(range(n),n): if i[0]==0: for j in range(n): if j==n-1: ans+...
s883530745
p03805
u633548583
1575144580
Python
Python (3.4.3)
py
Runtime Error
26
3064
413
import itertools n,m=map(int,input().split()) p=[[False]*n for i in range(n)] ans=0 for i in range(n): a,b=map(int,input().split()) a-=1 b-=1 p[a][b]=True p[b][a]=True for i in itertools.permutations(range(n),n): if i[0]==0: for j in range(n): if j==n-1: ans+...
s029238116
p03805
u379959788
1574996524
Python
Python (3.4.3)
py
Runtime Error
22
3064
760
# ABC054C # 方針:階乗の全探索 import itertools N, M = map(int, input().split()) # Graph の作成 graph = [[] * N for _ in range(N)] for i in range(M): u, v = map(int, input().split()) u -= 1 v -= 1 graph[u].append(v) graph[v].append(u) # パターンの全列挙 lst = [_ for _ in range(0, N)] search_list = itertools.permutati...
s297488662
p03805
u698902360
1574806070
Python
PyPy3 (2.4.0)
py
Runtime Error
187
45424
452
import itertools N, M = map(int, input().split()) graph = [[0] * N for i in range(N)] for i in range(N): a, b = map(int, input().split()) graph[a-1][b-1] = 1 graph[b-1][a-1] = 1 p = list(itertools.permutations(range(N))) Sum = 0 for i in range(len(p)): if p[i][0] != 0: break for j in ran...
s822907973
p03805
u814986259
1574726776
Python
Python (3.4.3)
py
Runtime Error
18
3064
428
from itertools import permutation N,M=map(int,input().split()) ab=[list(map(int,input().split())) for i in range(M)] g=[[False]*N for i in range(N)] for a,b in ab: g[a-1][b-1]=True g[b-1][a-1]=True nodes=[i for i in range(N)] ans=0 for route in permutation(nodes): for i in range(N): if i == N-1: ans+=1 ...
s500444273
p03805
u936985471
1574522354
Python
Python (3.4.3)
py
Runtime Error
18
3064
577
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] elif b not in nexts[a]: nexts[a].append(b) if nexts[b]==None: nexts[b]=[a] elif a not in nexts[b]: nexts[b].append(a) ans=0 stack=[] stack....
s719277604
p03805
u936985471
1574522297
Python
Python (3.4.3)
py
Runtime Error
17
3188
541
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] else: nexts[a].append(b) if nexts[b]==None: nexts[b]=[a] else: nexts[b].append(a) ans=0 stack=[] stack.append([0,[]]) while stack: node=s...
s717783700
p03805
u936985471
1574522170
Python
Python (3.4.3)
py
Runtime Error
17
3064
538
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] else: nexts[a].append(b) if nexts[b]==None: nexts[b]=[a] else: nexts[b].append(a) ans=0 stack=[] stack.append([0,set()]) while stack: nod...
s191965530
p03805
u936985471
1574521127
Python
Python (3.4.3)
py
Runtime Error
17
3064
538
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] else: nexts[a].append(b) if nexts[b]==None: nexts[b]=[a] else: nexts[b].append(a) ans=0 stack=[] stack.append([0,[]]) while stack: node=s...
s351491827
p03805
u936985471
1574521072
Python
Python (3.4.3)
py
Runtime Error
17
3064
533
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] else: nexts[a].append(b) if nexts[b]==None: nexts[b]=[a] else: nexts[b].append(a) ans=0 stack=[] stack.append([0,[]]) while stack: node=s...
s045993711
p03805
u936985471
1574520030
Python
Python (3.4.3)
py
Runtime Error
19
3188
461
n,m=map(int,input().split()) nexts=[None for i in range(n)] for i in range(n): a,b=map(int,input().split()) a,b=a-1,b-1 if nexts[a]==None: nexts[a]=[b] else: nexts[a].append(b) ans=0 stack=[] stack.append([0,set()]) while stack: node=stack.pop() v=node[0] seen=node[1] seen.add(v) if len(seen)...
s610820984
p03805
u322229918
1574471018
Python
Python (3.4.3)
py
Runtime Error
312
21800
495
from itertools import permutations import numpy as np N, M = map(int, input().split(" "))#N頂点M辺 mat = [[0] * n for _ in range(n)] for _ in range(M): v1, v2 = map(int, input().split(" ")) mat[v1 - 1][v2 - 1] = mat[v2 - 1][v1 - 1] = 1 count = 0 for line in permutations(np.arange(N - 1) + 2): vtxs = [1] + lis...
s987955988
p03805
u047178225
1574003200
Python
Python (3.4.3)
py
Runtime Error
17
3060
615
nmax = 8 graph = [[0]*nmax for i in range(nmax)] visited = [0] * nmax def dfs(v, N, visitied): all_visited = True for i in range(N): if visitied[i] == 0: all_visited = False if all_visited: return 1 ret = 0 for i in range(N): if graph[v][i] == 0: continue if visited[i] == 0...
s265274673
p03805
u557494880
1573891923
Python
Python (3.4.3)
py
Runtime Error
19
3064
402
N,M = map(int,input().split()) G = [[] for i in range(N+1)] for i in range(M): a,b = map(int,input().split()) G[a].append(b) G[b].append(a) l = [i for i in range(2,N+1)] import itertools ans = 0 for v in itertools.permutations(l): s = 1 t = 1 while v: s = t t = v.pop(0) i...
s589965427
p03805
u183896397
1573795661
Python
Python (3.4.3)
py
Runtime Error
18
3064
587
N,M = (int(i) for i in input().split()) K = [] for i in range(M): J = [int(i) for i in input().split()] J.sort() K.append(J) #1以外の頂点リストを作成 vertex = [] for i in range(N-1): vertex.append(i+2) #順列作成 X = list(itertools.permutations(vertex)) #各値ごとに有無をチェック ans = 0 for i in X: start = 1 localcount =...
s453090378
p03805
u183896397
1573794476
Python
Python (3.4.3)
py
Runtime Error
17
3064
627
N,M = (int(i) for i in input().split()) K = [] for i in range(M): J = [int(i) for i in input().split()] J.sort() K.append(J) #1以外の頂点リストを作成 vertex = [] for i in range(N-1): vertex.append(i+2) #順列作成 X = list(itertools.permutations(vertex)) #各値ごとに有無をチェック ans = 0 for i in X: start = 1 localcount =...
s382530249
p03805
u457423258
1573756886
Python
Python (3.4.3)
py
Runtime Error
35
8052
463
import itertools N,M=map(int,input().split()) if M==0: print(0) exit() S=[list(map(int,input().split()))for _ in range(N) ] a=[] for i in range(N): a.append(i+1) L=list(itertools.permutations(a)) cnt=0 for l in L: tmp=1 if l[0]!=1: break for j in range(N-1): if ([l[j],l[j+1...
s153051124
p03805
u457423258
1573756738
Python
Python (3.4.3)
py
Runtime Error
35
8052
430
import itertools N,M=map(int,input().split()) S=[list(map(int,input().split()))for _ in range(N) ] a=[] for i in range(N): a.append(i+1) L=list(itertools.permutations(a)) cnt=0 for l in L: tmp=1 if l[0]!=1: break for j in range(N-1): if ([l[j],l[j+1]] in S) or ([l[j+1],l[j]] in S):...
s605551234
p03805
u910756197
1573592487
Python
Python (3.4.3)
py
Runtime Error
29
3064
370
N, M = map(int, input().split()) g = [[] for _ in range(M + 1)] for _ in range(M): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) ans = 0 def walk(cur, visited): global ans tmp = visited + [cur] if len(tmp) == N: ans += 1 for nex in g[cur]: if nex not in tmp:...
s994663022
p03805
u910756197
1573592423
Python
Python (3.4.3)
py
Runtime Error
29
3064
374
N, M = map(int, input().split()) g = [list() for _ in range(M + 1)] for _ in range(M): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) ans = 0 def walk(cur, visited): global ans tmp = visited + [cur] if len(tmp) == N: ans += 1 for nex in g[cur]: if nex not in ...
s368847787
p03805
u910756197
1573592284
Python
Python (3.4.3)
py
Runtime Error
32
3064
395
N, M = map(int, input().split()) g = [list() for _ in range(M + 1)] for _ in range(M): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) ans = 0 def walk(cur, visited): global ans, g, N, M tmp = visited + [cur] if len(tmp) == N: ans += 1 for nex in g[cur]: if ne...
s636889416
p03805
u910756197
1573592132
Python
Python (3.4.3)
py
Runtime Error
31
3064
386
N, M = map(int, input().split()) g = [list() for _ in range(M + 1)] for _ in range(M): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) ans = 0 def walk(cur, visited): global ans tmp = visited + [cur] if len(tmp) == N: ans += 1 for nex in g[cur]: if nex not in ...
s208279989
p03805
u910756197
1573591894
Python
Python (3.4.3)
py
Runtime Error
17
3064
390
N, M = map(int, input().split()) g = [list() for _ in range(M + 1)] for _ in range(M): a, b = map(int, input().split()) g[a].append(b) g[b].append(a) ans = 0 def walk(cur, visited): global ans if cur == N: ans += 1 return visited.append(cur) for nex in g[cur]: if nex...
s106762227
p03805
u030749892
1572484932
Python
Python (3.4.3)
py
Runtime Error
18
3064
465
N,M = map(int,input().split()) x = [input().split() for i in range(M)] y = [[] for _ in range(M)] z = [0 for _ in range(M)] for i in x: y[int(i[0])-1].append(int(i[1])-1) y[int(i[1])-1].append(int(i[0])-1) tmp = y[0] ans = 0 cnt = 0 while True: if cnt != N - 1: tmp2 = [] for l in tmp: if z[l] == ...