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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s296699691 | p03575 | u941753895 | 1586853854 | Python | Python (3.4.3) | py | Runtime Error | 45 | 5172 | 1296 | import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy
sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys... |
s307469965 | p03575 | u145600939 | 1586400715 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 554 | from collections import deque
n,m = map(int,input().split())
path = [[] for _ in range(n)]
ab = [[] for _ in range(m)]
for i in ragne(m):
a,b = map(int,input().split())
a -= 1
b -= 1
ab[i] = (a,b)
path[a].append(b)
path[b].append(a)
def dfs(a,b):
que = deque()
reach = [False]*n
reach[0] = True
que.a... |
s816736137 | p03575 | u992910889 | 1586384310 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38512 | 524 | from scipy.sparse.csgraph import connected_components # https://note.nkmk.me/python-scipy-connected-components/
from scipy.sparse import csr_matrix
N, M = map(int, input().split()) # 頂点数、辺数
A, B, C = [0] * M, [0] * M, [1] * (M-1)
for i in range(M):
A[i], B[i] = map(int, input().split())
A[i]-=1
B[i]-=1
... |
s620239697 | p03575 | u992910889 | 1586384002 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 814 | def input(): return sys.stdin.readline().strip()
def resolve():
from scipy.sparse.csgraph import connected_components # https://note.nkmk.me/python-scipy-connected-components/
from scipy.sparse import csr_matrix
N, M = map(int, input().split()) # 頂点数、辺数
A, B, C = [0] * M, [0] * M, [1] * (M-1)
... |
s720065940 | p03575 | u811169796 | 1585792409 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 477 | n,m = map(int,input().split())
data = []
G = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
data.append((a-1,b-1))
G[a].append(b)
G[b].append(a)
def dfs(v,seen):
if seen[v]: return
seen[v] = True
for nv in G[v]:
dfs(nv,seen)
cnt = 0
for i in range(m):
... |
s379488859 | p03575 | u964299793 | 1585618130 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 719 | n,m=map(int,input().split())
g=[ [0 for _ in range(8)] for _ in range(8)]
a=[0]*m
b=[0]*m
for i in range(m):
a[i],b[i]=map(lambda x:int(x)-1,input().split())
g[a[i]][b[i]]=1
g[b[i]][a[i]]=1
ans=0
#print(g)
for i in range(m):
# print(i,end=' start i \n')
g[a[i]][b[i]]=0
g[b[i]][a[i]]=0
vis=[0]... |
s793030672 | p03575 | u808593466 | 1585564300 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1380 | // 深さ優先探索 計算量:O(N+M)
#include <bits/stdc++.h>
typedef long long ll;
#define MOD 1000000007
using namespace std;
const int limit = 50;
int n,m;
int a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];
void dfs(int v) {
visited[v] = true;
for (int v2 = 0; v2 < n; ++v2) {
if (graph[v][v2... |
s149010613 | p03575 | u576432509 | 1585521227 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1430 | icase=0
if icase==0:
n,m=map(int, input().split())
a=[]
b=[]
for i in range(m):
ai,bi=map(int, input().split())
a.appned(ai)
b.appned(bi)
elif icase==1:
n=6
m=5
# a=[[1],[2],[3],[4],[5]]
# b=[[2],[3],[4],[5],[6]]
a=[1,2,3,4,5]
b=[2,3,4,5,6]
elif icase==2:
... |
s821917530 | p03575 | u576432509 | 1585521186 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 1429 | icase=0
if icase==0:
n,m=map(int, input().split())
a=[]
b=[]
for i in range(m):
ai,bi=map(int, input().split())
a.appned(ai)
b.appned(bi)
elif icase==1:
n=6
m=5
# a=[[1],[2],[3],[4],[5]]
# b=[[2],[3],[4],[5],[6]]
a=[1,2,3,4,5]
b=[2,3,4,5,6]
elif icase==2:
... |
s627008116 | p03575 | u007550226 | 1585374649 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3140 | 742 | n,m= map(int,input().split())
henl = []
usehen = [False] * n
brdic = {}
for _ in range(m):
a,b= map(int,input().split())
brdic[a] = brdic.get(a,[]) + [b]
brdic[b] = brdic.get(b,[]) + [a]
henl.append((a,b))
ordin = [-1]*(n+1)
lowlink = [-1]*(n+1)
k=[1]
bn=[0]
def dfs(node):
ordin[node]=k[0]
k[0]... |
s756713520 | p03575 | u490553751 | 1585357001 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3316 | 1289 | #template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
... |
s173501832 | p03575 | u549383771 | 1585260588 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 846 | def dfs(graph,visited,initial):
global cnt
visited[initial] = 1
all_visited = True
for i in visited:
if i == 0:
all_visited = False
if all_visited == True:
cnt = 1
for i in range(len(graph)):
if graph[initial][i] == 1:
if visited[i] == 0... |
s469412548 | p03575 | u411203878 | 1584708449 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38256 | 590 | n,m = map(int,input().split())
count = 0
ab = []
for _ in range(m):
a, b = (int(x) for x in input().split())
ab.append([a, b])
for i in range(m):
root = [[] for i in range(n)]
done = [False]*n
cd = copy.copy(ab)
cd.pop(i)
for j in range(m-1):
a, b = cd[j]
root[b-1].append(a-... |
s650979730 | p03575 | u762420987 | 1584598302 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1355 | def int_(num_str):
return int(num_str) - 1
N, M = map(int, input().split())
ablist = [list(map(int_, input().split())) for _ in range(M)]
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
self.group_count = n
def find(self, x):
if self.parents[x]... |
s059670310 | p03575 | u762420987 | 1584593855 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 1314 | N, M = map(int, input().split())
ablist = [list(map(int, input().split())) for _ in range(M)]
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.fin... |
s537891337 | p03575 | u585482323 | 1584491830 | Python | PyPy3 (2.4.0) | py | Runtime Error | 234 | 42476 | 1588 | #!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for ... |
s871950984 | p03575 | u941434715 | 1583968550 | Python | Python (3.4.3) | py | Runtime Error | 219 | 12840 | 589 | #coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb
N,M = map(int, input().split())
G = [[] for _ in range(N)]
E = []
for _ in range(M):
a,b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
E.append((a-1... |
s575059185 | p03575 | u638795007 | 1583514085 | Python | Python (3.4.3) | py | Runtime Error | 66 | 8568 | 52913 | def JOI14_B():
N = I()
A = [I()for _ in range(N)]
A.extend(A)
dp = [[0]*(N*2+1) for _ in range(N*2+1)]
for j in range(N):
for i in range(N*2-j):
if (N-j)%2==1:
dp[i][i+j] = max(dp[i+1][i+j]+A[i],dp[i][i+j-1]+A[i+j])
else:
if A[i]>A[i+j... |
s390028199 | p03575 | u968404618 | 1583392378 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1078 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] = self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
g... |
s242409849 | p03575 | u968404618 | 1583392180 | Python | Python (3.4.3) | py | Runtime Error | 77 | 3928 | 1087 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s251012688 | p03575 | u968404618 | 1583392102 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1088 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s355043262 | p03575 | u968404618 | 1583392034 | Python | Python (3.4.3) | py | Runtime Error | 76 | 3928 | 1095 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s884618909 | p03575 | u968404618 | 1583391973 | Python | Python (3.4.3) | py | Runtime Error | 76 | 3920 | 1093 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s211395225 | p03575 | u968404618 | 1583391909 | Python | Python (3.4.3) | py | Runtime Error | 76 | 3924 | 1081 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s822561551 | p03575 | u968404618 | 1583391269 | Python | Python (3.4.3) | py | Runtime Error | 76 | 3924 | 1092 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s987901146 | p03575 | u968404618 | 1583391196 | Python | Python (3.4.3) | py | Runtime Error | 79 | 3964 | 1119 | # https://atcoder.jp/contests/abc075/tasks/abc075_c
class UnionFind():
def __init__(self, N):
self._root = [-1 for _ in range(N)]
def find(self, x):
if self._root[x] < 0: return x
self._root[x] == self.find(self._root[x])
return self._root[x]
def unite(self, x, y):
... |
s226950430 | p03575 | u094191970 | 1583284784 | Python | Python (3.4.3) | py | Runtime Error | 252 | 17432 | 426 | from scipy.sparse.csgraph import floyd_warshall
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
cnt=0
for i in range(m):
ll=deepcopy(l)
del ll[i]
d=[[float('inf')]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for a,b in ll:
a-=1
b-=1
d[a][b]=1
d[b... |
s706933702 | p03575 | u474423089 | 1583160293 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 917 | class UnionFind:
def __init__(self,N):
self.par =[-1 for i in range(N)]
def find(self,x):
if self.par[x] < 0:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
def unite(self,x,y):
x = self.find(x)
y = self.fin... |
s875880363 | p03575 | u746849814 | 1583009091 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 544 | ## import numpy as np
from collections import defaultdict
n, m = map(int, input().split())
AB = []
G = defaultdict(list)
for _ in range(m):
a, b = map(int, input().split())
AB.append([a, b])
G[a].append(b)
G[b].append(a)
ans = 0
for a, b in AB:
memo = [0]*(n+1)
memo[a] = 1
que = [c for c ... |
s390650964 | p03575 | u968846084 | 1582940141 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3316 | 535 | from collections import deque
n,m=map(int,input().split())
A=[[0]*2 for i in range(n)]
for i in range(m):
A[i]=list(map(int,input().split()))
ans=0
for i in range(m):
B=[[] for i in range(n)]
for j in range(m):
if j==i:
continue
B[A[j][0]-1].append(A[j][1]-1)
B[A[j][1]-1].append(A[j][0]-1)
C=[... |
s747004382 | p03575 | u882039496 | 1582655646 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 2955 |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#defin... |
s800416222 | p03575 | u762540523 | 1582313782 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 1404 | class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = ... |
s583777624 | p03575 | u686036872 | 1582106256 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 382 | N, M = map(int, input().split())
d=[[] for i in range(N)]
for i in range(M):
b, c = map(int, input().split())
l[b-1].append(c-1)
l[c-1].append(b-1)
a=0
while True:
count = 0
for i in range(N):
if len(d[i]) == 1:
d[d[i][0]].remove(i)
d[i]=[]
count += 1
... |
s534136775 | p03575 | u686036872 | 1582106130 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3064 | 458 | N, M = map(int, input().split())
d=[[] for i in range(N)]
for i in range(M):
b, c = map(int, input().split())
for j in range(N):
if b == j:
d[j-1].append(c-1)
if c == j:
d[j-1].append(b-1)
a=0
while True:
count = 0
for i in range(N):
if len(d[i]) == 1:
... |
s870977503 | p03575 | u686036872 | 1582106079 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 3064 | 454 | N, M = map(int, input().split())
d=[[] for i in range(N)]
for i in range(M):
b, c = map(int, input().split())
for j in range(N):
if b == j:
d[j-1].append(c-1)
if c == j:
d[j-1].append(b-1)
while True:
count = 0
for i in range(N):
if len(d[i]) == 1:
... |
s390260184 | p03575 | u686036872 | 1582105930 | Python | Python (3.4.3) | py | Runtime Error | 2103 | 3064 | 459 | N, M = map(int, input().split())
d=[[] for i in range(N)]
for i in range(M):
b, c = map(int, input().split())
for j in range(1, N+1):
if b == j:
d[j-1].append(c-1)
if c == j:
d[j-1].append(b-1)
while True:
count = 0
for i in range(N):
if len(d[i]) == 1:
... |
s748213891 | p03575 | u958224692 | 1577807577 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 803 | import sys
sys.setrecursionlimit(10**6)
N, M = map(int, input().split())
G = {k:[] for k in range(N)}
for _ in range(M):
a, b = map(int, input().split())
G[a-1].append(b-1)
G[b-1].append(a-1)
def rel_side(v, G): # 任意の頂点から、他のすべての頂点を訪問したかどうかを確認する関数
if all(vis):
return 1
r = 0
for side in G[v]:
i... |
s159727811 | p03575 | u492447501 | 1577233170 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 653 | import sys
import copy
N, M = map(int, input().split())
V = []
E = []
for i in range(N):
V.append(set())
for i in range(M):
*l, = map(int, input().split())
V[l[0]-1].add(l[1]-1)
V[l[1]-1].add(l[0]-1)
E.append([l[0], l[1]])
count = 0
E_copy = copy.deepcopy(E)
V_copy = copy.deepcopy(V)
for i ... |
s991355805 | p03575 | u371990949 | 1576590092 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1149 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.ranks = [0] * n
self.count = n
def union(self, x, y):
self.link(x, y)
def link(self, x, y):
x_root = self.parents[x]
y_root = self.parents[y]
if x_r... |
s936170786 | p03575 | u371990949 | 1576587657 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1431 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.ranks = [0] * n
self.count = n
def union(self, x, y):
self.link(x,y)
def link(self, x, y):
if self.parents[x] == self.parents[y]:
return
if self... |
s846990665 | p03575 | u371990949 | 1576587603 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1245 | class UnionFind:
def __init__(self, n):
self.n = n
self.parents = [i for i in range(n)]
self.ranks = [0] * n
self.count = n
def union(self, x, y):
self.link(x,y)
def link(self, x, y):
if self.parents[x] == self.parents[y]:
return
if self... |
s608701309 | p03575 | u305366205 | 1576559785 | Python | Python (3.4.3) | py | Runtime Error | 2143 | 658292 | 764 | import sys
sys.setrecursionlimit(10 ** 8)
n, m = map(int, input().split())
g = [[False] * n for _ in range(n)]
visited = [False] * n
a = []
b = []
ans = 0
def dfs(v):
visited[v] = True
for to in range(n):
if not g[v][to]:
continue
if visited[to]:
continue
dfs(v)... |
s812140878 | p03575 | u727787724 | 1576511808 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3064 | 1295 | """
頂点数nと隣接リストesが与えられて, そのグラフが木か連結かどちらでもないか判定する
"""
n,m = map(int,input().split())# 頂点数
es = []
ans=-1
for i in range(n):
es.append([])
for j in range(m):
a,b=map(int,input().split())
es[a-1].append(b-1)
es[b-1].append(a-1)
tmp=0
for i in range(m):
for j in range(m):
if i==j:
if ... |
s546111643 | p03575 | u846634344 | 1576200641 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 1320 | import sys
if sys.platform =='ios':
sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]
def dfs(G, v):
seen[v] += 1
#print('v :', v)
for nv in G[v]:
if seen[nv]: continue
#print('v nv :', v, nv, 'Recursion')
dfs(G, nv... |
s521936230 | p03575 | u936985471 | 1575501373 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 621 | N,Mmap(int,input())
e=[[] for i in range(N)]
tester=[None]*M
for i in range(M):
a,b=map(int,input().split())
a,b=a-1,b-1
e[a].append(b)
e[b].append(a)
tester[i]=set(a,b)
ans=0
seen=[0 for i in range(N)]
for test in tester:
stack=[]
stack.append([0,-1])
while stack:
node=stack.pop()
v=node[0]
... |
s178156998 | p03575 | u514894322 | 1575466242 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 598 | n,m = map(int,input().split())
ll =[[0]*n for _ in [0]*n]
edges = [list(map(int,input().split())) for _ in [0]*m]
for edge in edges:
ll[edge[0]][edge[1]] = 1
ll[edge[1]][edge[0]] = 1
originalll = ll.copy()
seen = [0]*n
ans = 0
for edge in edges:
ll = originalll.copy()
ll[edge[0]][edge[1]] = 0
ll[edge[1]][edg... |
s219508081 | p03575 | u514894322 | 1575465921 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 365 | n,m = map(int,input().split())
ll =[[0]*n for _ in [0]*n]
edges = [list(map(int,input().split())) for _ in [0]*m]
for edge in edges:
ll[edge[0]][edge[1]] = 1
ll[edge[1]][edge[0]] = 1
originalll = ll.copy()
seen = [0]*n
ans = 0
def dfs(seen,tmp,ll):
for i in range(n):
if ll[tmp][i] = 1 and seen[i] = 0
see... |
s364949793 | p03575 | u948524308 | 1574987381 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3064 | 729 | N,M=map(int,input().split())
graph=[[False]*N for i in range(N)]
visited=[False]*N
a=[0]*N
b=[0]*N
for i in range(M):
a[i],b[i]=map(int,input().split())
a[i]-=1
b[i]-=1
graph[a[i]][b[i]]=True
graph[b[i]][a[i]]=True
def dfs(v):
visited[v]=True
for v2 in range(N):
if graph[v][v2]==... |
s607653669 | p03575 | u047178225 | 1574932321 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 212 | N, M = [int(i) for i in input().split()]
for j in range(M):
a, b = [int(k) for k in input().split()]
graph[a-1][b-1] = graph[b-1][a-1] = 1
nmax = 50
graph = [[0]*nmax for i in range(nmax)]
print(*graph) |
s246285706 | p03575 | u821712904 | 1574517327 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 635 | n,m=map(int,input().split())
a1=[0]*m
b1=[0]*m
for i in range(m):
a1[i],b1[i]=map(int,input().split())
ans=0
a,b=a1,b1
for i in range(m):
a=[int(a1[i]) for i in range(m)]
b=[int(b1[i]) for i in range(m)]
a.pop(i)
b.pop(i)
for j in range(n):
for k in range(n):
if j!=k:
for l1,l2 in zip(a,b)... |
s833666871 | p03575 | u821712904 | 1574517256 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 634 | n,m=map(int,input().split())
a1=[0]*m
b1=[0]*m
for i in range(m):
a1[i],b1[i]=map(int,input().split())
ans=0
a,b=a1,b1
for i in range(m):
a=[int(a1[i]) for i in range(m)]
b=[int(b1[i]) for i in range(m)]
a.pop(i)
b.pop(i)
for j in range(n):
for k in range(n):
if j!=k
for l1,l2 in zip(a,b):... |
s946474395 | p03575 | u821712904 | 1574516469 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 484 | n,m=map(int,input().split())
a1=[0]*m
b1=[0]*m
for i in range(m):
a1[i],b1[i]=map(int,input().split())
ans=0
a,b=a1,b1
for i in range(m):
a,b=a1,b1
a.pop(i)
b.pop(i)
for j in range(n):
for k in range(n):
for l1,l2 in zip(a,b):
if l1==j:
j=l2
if j==k:
break
i... |
s132785908 | p03575 | u821712904 | 1574515559 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 490 | n,m=map(int,input().split())
a1=[0]*m
b1=[0]*m
for i in range(m):
a1[i],b1[i]=map(int,input().split())
ans=0
a,b=a1,b1
for i in range(m):
a,b=a1,b1
a.pop(a[i])
b.pop(b[i])
for j in range(n):
for k in range(n):
for l1,l2 in zip(a,b):
if l1==j:
j=l2
if j==k:
break
... |
s272317398 | p03575 | u821712904 | 1574515377 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 563 | n,m=map(int,input().split())
a1=[0]*m
b1=[0]*m
for i in range(m):
a1[i],b1[i]=map(int,input().split())
ans=0
a,b=a1,b1
for i in range(m):
a.pop(a[i])
b.pop(b[i])
for j in range(n):
for k in range(n):
for l1,l2 in zip(a,b):
if l1==j:
j=l2
if j==k:
break
if l1!=... |
s395358933 | p03575 | u311379832 | 1574487821 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3168 | 812 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N, M = map(int, input().split())
k = [[] for _ in range(N)]
flst = [list([0] * 2) for _ in range(M)]
for i in range(M):
a, b = map(int, input().split())
k[b - 1].append(a - 1)
k[a - 1].append(b - 1)
flst[i][0] = a
flst[i][1] = b
... |
s727264082 | p03575 | u987164499 | 1574436688 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38384 | 867 | from sys import stdin
import math
import bisect
import heapq
import numpy as np
from math import factorial
inf = 10**3
n,m = [int(x) for x in stdin.readline().rstrip().split()]
li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
nu = []
def warshall_floyd(d):
#d[i][j]: iからjへの最短距離
#k:中継
... |
s297311077 | p03575 | u614875193 | 1573683610 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 732 | N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
def UF_make(Graph):
ret=[-1]*(N+1)
for i in range(len(Graph)):
v1=[ret[Graph[i][0]],Graph[i][0]][ret[Graph[i][0]]<0]
v2=[ret[Graph[i][1]],Graph[i][1]][ret[Graph[i][1]]<0]
if v1!=v2:
if ret[v1... |
s008961605 | p03575 | u223904637 | 1571414837 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 543 | n,m=map(int,input().split())
e=[]
for i in range(m):
e.append(list(map(int,input().split())))
ans=0
for i in range(m):
g=[[] for _ in range(n)]
for j in range(m):
if i==j:
continue
g[e[j][0]-1].append(e[j][1])
g[e[j][1]-1].append(e[j][0])
visited=[0]*n
visited[0]=... |
s489136415 | p03575 | u223904637 | 1571414029 | Python | Python (3.4.3) | py | Runtime Error | 55 | 3064 | 932 | n,m=map(int,input().split())
e=[]
for i in range(n):
e.append(list(map(int,input().split())))
ans=0
for i in range(m):
nall=[]
for j in range(m):
if i==j:
continue
nall.append(e[j])
visited=[0]*n
visited[0]=1
t=[1]
while len(t)>0:
tmp=[]
ntmp=[]
... |
s852028927 | p03575 | u223904637 | 1571411438 | Python | Python (3.4.3) | py | Runtime Error | 2107 | 79656 | 844 | n,m=map(int,input().split())
e=[]
for i in range(n):
e.append(list(map(int,input().split())))
ans=0
for i in range(m):
nall=[]
for j in range(m):
if i==j:
continue
nall.append(e[j])
visited=[0]*n
t=[1]
while len(t)>0:
tmp=[]
ntmp=[]
for p in t:... |
s462656009 | p03575 | u922487073 | 1570993703 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3064 | 747 | N, M = list(map(int, input().split()))
lines = [list(map(int, input().split())) for _ in range(M)]
graph = [[False] * N for _ in range(N)]
for a,b in lines:
graph[a-1][b-1] = graph[b-1][a-1] = True
visited = [False for _ in range(N)]
def DFS(v):
visited[v] = True
for from_v in range(N):
if not gr... |
s531384434 | p03575 | u970197315 | 1570890096 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3068 | 11 | atodeyaruyo |
s656327506 | p03575 | u094191970 | 1570508703 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38384 | 415 | from scipy.sparse.csgraph import floyd_warshall
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ans=0
for i in range(m):
ll=l[:i]+l[i+1:]
d=[[float('inf')]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for j in ll:
d[j[0]-1][j[1]-1]=1
d[j... |
s739941055 | p03575 | u094191970 | 1570508679 | Python | PyPy3 (2.4.0) | py | Runtime Error | 168 | 38384 | 415 | from scipy.sparse.csgraph import floyd_warshall
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
ans=0
for i in range(m):
ll=l[:i]+l[i+1:]
d=[[float('inf')]*n for i in range(n)]
for i in range(n):
d[i][i]=0
for j in ll:
d[j[0]-1][j[1]-1]=1
d[j... |
s589201599 | p03575 | u196697332 | 1570226178 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 768 | from collections import deque
N, M = map(int, input().split())
graph = [set() for _ in range(N + 1)]
edge = [[] for _ in range(N + 1)]
for m in range(M):
a, b = map(int, input().split())
graph[a].add(b)
graph[b].add(a)
edge[m + 1] = [a, b]
ans = 0
for m in range(M):
Bridge = True
fr, to = edge... |
s385767573 | p03575 | u196697332 | 1570225939 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3316 | 781 | from collections import deque
N, M = map(int, input().split())
graph = [[] for _ in range(N + 1)]
edge = [[] for _ in range(N + 1)]
for m in range(M):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
edge[m + 1] = [a, b]
ans = 0
for m in range(M):
Bridge = True
fr, to = e... |
s579325820 | p03575 | u196697332 | 1570225765 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 767 | from collections import deque
N, M = map(int, input().split())
graph = [[] for _ in range(N + 1)]
edge = [[] for _ in range(N + 1)]
for m in range(M):
a, b = map(int, input().split())
graph[a].append(b)
graph[b].append(a)
edge[m + 1] = [a, b]
ans = 0
for m in range(M):
Bridge = True
fr, to = e... |
s030055562 | p03575 | u714225686 | 1568591595 | Python | PyPy3 (2.4.0) | py | Runtime Error | 263 | 63980 | 2285 | import sys
import math
from fractions import gcd
from copy import deepcopy
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce
def lcm(a, b):
return a * b // gcd(a, b)
def combination_count(n, r):
return math.factorial(n) // (math.factorial(n - r)... |
s055378940 | p03575 | u008229752 | 1568425650 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 1411 | #include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define crep(i) for(char i=... |
s436312101 | p03575 | u263933075 | 1568253376 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 979 | #include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<iomanip>
#include<stack>
#include<queue>
#include<ctime>
#include<osstream>//
#include<isstream>//
using namespace std;
const int maxn=500;
vector<int> G[maxn];
int dfn[maxn],low[maxn];
int n,m,u,v,dep,ans;
void init()
{
dep=ans=0;
... |
s289839635 | p03575 | u405660020 | 1567633075 | Python | Python (3.4.3) | py | Runtime Error | 293 | 17864 | 399 | from scipy.sparse.csgraph import dijkstra
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
graph = [[0]*(n+1) for _ in range(n+1)]
for a, b in ab:
graph[a][b] = 1
ans = 0
inf = 10**9
for a, b in ab:
graph[a][b] = inf
dist = dijkstra(graph, indices = a, directed = ... |
s698402121 | p03575 | u405660020 | 1567633013 | Python | Python (3.4.3) | py | Runtime Error | 250 | 17460 | 403 | from scipy.sparse.csgraph import dijkstra
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
graph = [[0]*(n+1) for _ in range(n+1)]
for a, b in ab:
graph[a-1][b-1] = 1
ans = 0
inf = 10**9
for a, b in ab:
graph[a][b] = inf
dist = dijkstra(graph, indices = a, directe... |
s882782522 | p03575 | u484710012 | 1566948668 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 686 | def dfs(num):
global visited
for next_num in num:
if visited[next_num]:
continue
if has_edge[num][next_num]:
visited[next_num]=1
dfs(next_num)
N,M = map(int,input().split())
ab = []
edge = [[] for x in range(N+1)]
has_edge = [[0 for x in range(N+1)] for x in range(N+1)]
for i in ran... |
s746414221 | p03575 | u111365362 | 1565477331 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 465 | h,w = map(int,input().split())
raw = ['/' * (w+2)]
for hi in range(h):
raw.append('/' + input() + '/')
raw += ['/' * (w+2)]
#print(raw)
for hi in range(h):
ans = ''
pre = raw[hi]
now = raw[hi+1]
pst = raw[hi+2]
for wi in range(w):
if now[wi+1] == '#':
cnt = '#'
else:
cnt = 0
can = ... |
s640805105 | p03575 | u498620941 | 1561373109 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3064 | 832 | import sys
sys.setrecursionlimit(10**9+7)
def check(graph,seen,now):
seen[now] = True
for i in range(len(graph[now])):
if seen[i] :
continue
if graph[now][i] == 0 :
continue
check(graph,seen,i)
return seen
#入力
N,M = map(int,input().split())
para = [[i for i... |
s703586079 | p03575 | u498620941 | 1561372991 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3064 | 829 | import sys
sys.setrecursionlimit(10000)
def check(graph,seen,now):
seen[now] = True
for i in range(len(graph[now])):
if seen[i] :
continue
if graph[now][i] == 0 :
continue
check(graph,seen,i)
return seen
#入力
N,M = map(int,input().split())
para = [[i for i i... |
s931647502 | p03575 | u498620941 | 1561372900 | Python | Python (3.4.3) | py | Runtime Error | 25 | 3064 | 981 | """
一本を外して、それが非連結であるのかの判定をしていく
"""
#連結かどうかの判定
#得られている辺をたどって全ノードにたどり着けたらOK
def check(graph,seen,now):
seen[now] = True
for i in range(len(graph[now])):
if seen[i] :
continue
if graph[now][i] == 0 :
continue
check(graph,seen,i)
return seen
#入力
N,M = map(int,i... |
s939063564 | p03575 | u298297089 | 1560934034 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3316 | 853 | from collections import deque
def dfs(graph, start, goal):
stack = deque()
push, pop = stack.append, stack.pop
push(start)
visited = [False for i in range(N)]
visited[start] = True
while stack:
a = pop()
for b in graph[a].keys():
if a in [start, goal] and b in [... |
s614945898 | p03575 | u838644735 | 1560638878 | Python | PyPy3 (2.4.0) | py | Runtime Error | 195 | 43244 | 721 | l = input().split()
N = int(l[0])
M = int(l[1])
C = []
for i in range(M):
l = input().split()
C.append([int(x) - 1 for x in l])
# print(N, M, C)
def visit(s, G, visited):
# print(s, G, visited)
visited.add(s)
for g in G:
if g[0] in visited:
n = g[1]
G.remove(g)
... |
s562786650 | p03575 | u497046426 | 1560181933 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1772 | class UnionFind:
def __init__(self, N):
# negative value: represents the root of a tree; its absolute value is the size of the tree
# positive value: the parent's index
self.vertices = [-1 for _ in range(N)]
self.rank = [0] * N
def find(self, v):
if self.vertices... |
s000636244 | p03575 | u497046426 | 1560181886 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 1772 | class UnionFind:
def __init__(self, N):
# negative value: represents the root of a tree; its absolute value is the size of the tree
# positive value: the parent's index
self.vertices = [-1 for _ in range(N)]
self.rank = [0] * N
def find(self, v):
if self.vertices... |
s765080487 | p03575 | u722535636 | 1559942230 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 352 | n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
g[a].append(b)
g[b].append(a)
cnt=0
def dfs(r,x,s):
ed[x-1]=1
for i in g[x]:
if i!=r and s!={x,i} and ed[i-1]==0:dfs(x,i,s)
cnt=0
for i in range(m):
ed=[0]*n
dfs(0,i+1,set(side[i]... |
s790377400 | p03575 | u722535636 | 1559942000 | Python | Python (3.4.3) | py | Runtime Error | 79 | 3940 | 325 | n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
g[a].append(b)
g[b].append(a)
cnt=0
def dfs(r,x,s):
ed[x-1]=1
for i in g[x]:
if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in side:
ed=[0]*n
dfs(0,1,set(i))
if 0 in ed:cnt+=1
print... |
s929938263 | p03575 | u722535636 | 1559941468 | Python | Python (3.4.3) | py | Runtime Error | 80 | 3936 | 335 | n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
g[a].append(b)
g[b].append(a)
cnt=0
def dfs(r,x,s):
ed[x-1]=1
for i in g[x]:
if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in range(m):
ed=[0]*n
dfs(0,1,set(side[i]))
if 0 in ed:cn... |
s119986764 | p03575 | u722535636 | 1559940947 | Python | Python (3.4.3) | py | Runtime Error | 79 | 3940 | 337 | n,m=map(int,input().split())
g=[list() for _ in range(n+1)]
side=[list(map(int,input().split())) for i in range(m)]
for a,b in side:
g[a].append(b)
g[b].append(a)
cnt=0
def dfs(r,x,s):
ed[x-1]=1
for i in g[x]:
if i!=r and s!={x,i}:dfs(x,i,s)
cnt=0
for i in range(m):
ed=[0]*n
dfs(0,i+1,set(side[i]))
if 0 in ed:... |
s226913864 | p03575 | u505420467 | 1558734194 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 478 | n,m = map(int,input().split())
a,B,ans = [[] for _ in range(n)],[],0
def solve(v,a,b):
visited[v] = True
for n in a[v]:
if not visited[n] and set([v,n]) != set([a,b]):
solve(n,a,b)
for i in range(m):
a,b = map(int,input().split())
a[a-1].append(b-1)
a[b-1].append(a-1)
B.appe... |
s597271941 | p03575 | u172035535 | 1558387397 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 352 | def f(L,res):
for i in range(1,M+1):
#print(i,L[i])
if len(L[i]) == 1:
L[L[i][0]].remove(i)
L[i] = []
res = f(L,res+1)
return res
N,M = map(int,input().split())
L = [[] for _ in range(N+1)]
for i in range(M):
a,b = map(int,input().split())
L[a].append(b)
... |
s652559499 | p03575 | u665038048 | 1557074829 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 709 | const int limit = 50;
int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];
void dfs(int v){
visited[v] = true;
for (int v2=0; v2<n;++v2){
if (graph[v][v2]==false) continue;
if (visited[v2]==true) continue;
dfs(v2);
}
}
int main(void){
cin >> n >> m... |
s160686725 | p03575 | u055941944 | 1556829800 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 438 | n,m=map(int,input().split())
x=[[] for i in range(n)]
for i in range(m):
a,b=map(int,input().split())
if b not in x[a-i]:
x[a-1].append(b)
if a not in x[b-i]:
x[b-1].append(a)
ans=0
while True:
idx,flg=0,0
for i in x:
if len(i)==1:
flg=1
x[... |
s395799066 | p03575 | u603745966 | 1556750132 | Python | PyPy3 (2.4.0) | py | Runtime Error | 185 | 38640 | 2309 | from functools import reduce
import math
import copy
def main():
# 文字列の2進数を数値にする
# '101' → '5'
# 文字列の頭に'0b'をつけてint()にわたす
# binary = int('0b'+'101',0)
# 2進数で立っているbitを数える
# 101(0x5) → 2
# cnt_bit = bin(5).count('1')
# N! を求める
# f = math.factorial(N)
# N の逆元
# N_inv = po... |
s184648571 | p03575 | u190405389 | 1555994706 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38768 | 803 | import numpy as np
n,m = map(int, input().split())
connect = np.zeros((n,n))
for i in range(m):
a, b = map(int, input().split())
connect[a-1, b-1] = 1
connect[b-1, a-1] = 1
notbridge = 0
for i in range(n):
for j in range(n):
if connect[i,j] == 1:
connect[i,j] = 0
co... |
s491977890 | p03575 | u249447366 | 1555970645 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 264 | N, M = map(int, input().split())
f = [True] * M
v = [0] * N
for i in range(M):
a, b = map(int, input().split())
a -= 1
b -= 1
if v[a] == 0:
v[a] = b
else:
f[a] = False
f[b] = False
f[v[a]] = False
print(sum(f))
|
s120026210 | p03575 | u315485238 | 1555518918 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 1107 | class UnionFind():
def __init__(self):
self.roots = {}
self.nums = {}
def find_root(self, a):
if a not in self.roots:
self.nums[a] = 1
return a
else:
self.roots[a] = self.find_root(self.roots[a])
return self.roots[a]
def unite(self, a, b):
root_a = self.find_root(a)
... |
s369189815 | p03575 | u310678820 | 1554420807 | Python | Python (3.4.3) | py | Runtime Error | 154 | 3064 | 1083 | n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
class UnionFind(object):
def __init__(self, size):
self.parent = [i for i in range(size)]
self.rank = [0 for _ in range(size)]
def find(self, x):
if self.parent[x] == x:
return x
... |
s096918963 | p03575 | u013408661 | 1554173475 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 689 | import sys
n,m=map(int,input().split())
vertex=[[int(i) for i in l.split()] for l in sys.stdin]
def generate(x):
root=[i for i in range(1,x+1)]
size=[0]*x
def find(x):
if root[x]==x:
return x
return find(root[x])
def check(x,y):
return find(x)==find(y)
def union(x,y):
x=find(x)
y=find(y)
if size[x]>... |
s382909095 | p03575 | u543954314 | 1553286741 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 471 | from collections import defaultdict as dd
n,m = map(int, input().split())
dic = dd(list)
l = []
cnt = 0
for _ in range(m):
a,b = map(int, input().split())
l.append(a,b)
dic[a].add(b)
dic[b].add(a)
def con(x):
visit.add(x)
for i in [j for j in dic[x] if j not in visited]:
con(i)
return visit == set(ran... |
s421436367 | p03575 | u887207211 | 1552426174 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 362 | N, M = map(int,input().split())
v = list(range(1,M+1))
edges = [[] for _ in range(M+1)]
for _ in range(M):
a, b = map(int,input().split())
edges[a] += [b]
edges[b] += [a]
def dfs(v, e):
for x in v:
if(len(e[x]) == 1):
t = e[x][0]
e[x] = []
e[t].remove(x)
v.remove(x)
return df... |
s979952789 | p03575 | u887207211 | 1552426131 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 358 | N, M = map(int,input().split())
v = list(range(1,M+1))
edges = [[] for _ in range(M+1)]
for _ in range(M):
a, b = map(int,input().split())
edges[a] += [b]
edges[b] += [a]
def f(v, e):
for x in v:
if(len(e[x]) == 1):
t = e[x][0]
e[x] = []
e[t].remove(x)
v.remove(x)
return f(v,... |
s757529570 | p03575 | u887207211 | 1552426112 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 360 | N, M = map(int,input().split())
v = list(range(1,M+1))
edges = [[] for _ in range(M+1)]
for _ in range(M):
a, b = map(int,input().split())
edges[a] += [b]
edges[b] += [a]
def dfs(v, e):
for x in v:
if(len(e[x]) == 1):
t = e[x][0]
e[x] = []
e[t].remove(x)
v.remove(x)
return df... |
s677467344 | p03575 | u160244242 | 1551930471 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 1124 | # UnionFind構造
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n+1)]
self.rank = [0] * (n+1)
# 検索
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
# 併合... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.