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
s639341335
p02561
u571969099
1599681946
Python
PyPy3 (7.3.0)
py
Runtime Error
94
68784
3579
from collections import deque class mf_graph: def __init__(self,N): self.N = N self.graph = [[] for _ in range(N)] def add_edge(self,v,w,cap): edge = (w,cap,None) edge[2] = rev_edge = (v,0,edge) self.graph[v].append(edge) self.graph[w].append(rev_edge) ...
s503529166
p02561
u779805689
1599681746
Python
PyPy3 (7.3.0)
py
Runtime Error
5520
178924
5825
class Weigthed_Digraph: #入力定義 def __init__(self,vertex=[]): self.vertex=set(vertex) self.edge_number=0 self.vertex_number=len(vertex) self.adjacent_out={v:{} for v in vertex} #出近傍(vが始点) self.adjacent_in={v:{} for v in vertex} #入近傍(vが終点) #頂点の追加 def add_vertex(se...
s457231643
p02561
u779805689
1599681431
Python
PyPy3 (7.3.0)
py
Runtime Error
5520
179932
5837
class Weigthed_Digraph: #入力定義 def __init__(self,vertex=[]): self.vertex=set(vertex) self.edge_number=0 self.vertex_number=len(vertex) self.adjacent_out={v:{} for v in vertex} #出近傍(vが始点) self.adjacent_in={v:{} for v in vertex} #入近傍(vが終点) #頂点の追加 def add_vertex(se...
s864157185
p02561
u779805689
1599675995
Python
PyPy3 (7.3.0)
py
Runtime Error
5519
179460
5916
class Weigthed_Digraph: #入力定義 def __init__(self,vertex=[]): self.vertex=set(vertex) self.edge_number=0 self.vertex_number=len(vertex) self.adjacent_out={v:{} for v in vertex} #出近傍(vが始点) self.adjacent_in={v:{} for v in vertex} #入近傍(vが終点) #頂点の追加 def add_vertex(se...
s179098328
p02561
u218843509
1599655164
Python
Python (3.8.2)
py
Runtime Error
406
67036
1058
import networkx as nx from networkx.algorithms.bipartite import hopcroft_karp_matching n, m = map(int, input().split()) def inside(x, y): if 0 <= x < n and 0 <= y < m: return True else: return False DI = [1, 0, -1, 0] DJ = [0, 1, 0, -1] a = [list(input()) for _ in range(n)] g = nx.Graph() g.add_nodes_from(ran...
s469591788
p02561
u218843509
1599655029
Python
Python (3.8.2)
py
Runtime Error
411
66852
1139
import networkx as nx from networkx.algorithms.bipartite import hopcroft_karp_matching n, m = map(int, input().split()) def inside(x, y): if 0 <= x < n and 0 <= y < m: return True else: return False DI = [1, 0, -1, 0] DJ = [0, 1, 0, -1] a = [list(input()) for _ in range(n)] g = nx.Graph() for i in range(0, n*...
s909086160
p02561
u218843509
1599652186
Python
Python (3.8.2)
py
Runtime Error
5516
94724
1218
import networkx as nx from networkx.algorithms.flow import dinitz n, m = map(int, input().split()) def inside(x, y): if 0 <= x < n and 0 <= y < m: return True else: return False DI = [1, 0, -1, 0] DJ = [0, 1, 0, -1] a = [list(input()) for _ in range(n)] S, T = n*m, n*m+1 g = nx.DiGraph() for i in range(n): f...
s334212784
p02561
u218843509
1599647795
Python
Python (3.8.2)
py
Runtime Error
5516
94764
1065
import networkx as nx from networkx.algorithms.flow import dinitz n, m = map(int, input().split()) def inside(x, y): if 0 <= x < n and 0 <= y < m: return True else: return False DI = [1, 0, -1, 0] DJ = [0, 1, 0, -1] a = [list(input()) for _ in range(n)] S, T = n*m, n*m+1 g = nx.DiGraph() for i in range(n): f...
s865021521
p02561
u201928947
1599643346
Python
PyPy3 (7.3.0)
py
Runtime Error
94
73144
3090
from collections import deque class mf_graph: def __init__(self,N): self.N = N self.graph = [[] for _ in range(N)] def add_edge(self,v,w,cap): edge = [w,cap,None] edge[2] = rev_edge = [v,0,edge] self.graph[v].append(edge) self.graph[w].append(rev_edge) ...
s972025420
p02561
u201928947
1599642591
Python
PyPy3 (7.3.0)
py
Runtime Error
87
68920
3032
from collections import deque class mf_graph: def __init__(self,N): self.N = N self.graph = [[] for _ in range(N)] def add_edge(self,v,w,cap): edge = [w,cap,None] edge[2] = rev_edge = [v,0,edge] self.graph[v].append(edge) self.graph[w].append(rev_edge) ...
s713406105
p02561
u201928947
1599642350
Python
PyPy3 (7.3.0)
py
Runtime Error
120
78104
3041
from collections import deque class mf_graph: def __init__(self,N): self.N = N self.graph = [[] for _ in range(N)] def add_edge(self,v,w,cap): edge = [w,cap,None] edge[2] = rev_edge = [v,0,edge] self.graph[v].append(edge) self.graph[w].append(rev_edge) ...
s222050328
p02561
u183395797
1599638389
Python
Python (3.8.2)
py
Runtime Error
885
66428
960
import networkx as nx R, C = [int(x) for x in input().split()] grid = [list(input()) for r in range(R)] def pack(r, c): return r * C + c graph = nx.Graph() for r in range(R - 1): for c in range(C - 1): if grid[r][c] == grid[r + 1][c] == ".": graph.add_edge(pack(r, c), pack(r + 1, c)) ...
s438992986
p02561
u498487134
1599599608
Python
PyPy3 (7.3.0)
py
Runtime Error
493
92896
4152
""" sから奇数へ,奇数から偶数へ,偶数からtへ """ def main(): # Dinic's algorithm import collections class Dinic: def __init__(self, vnum): self.edge = [[] for i in range(vnum)] self.n = vnum self.inf = 10**10 def add_edge(self, start, end, c): self.edge[start].a...
s891698174
p02561
u021548497
1599581798
Python
Python (3.8.2)
py
Runtime Error
244
19372
3290
import sys from collections import deque sys.setrecursionlimit(100000) input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [0]*v self.iter = [0]*v def add_edge(self, fr...
s389574606
p02561
u021548497
1599581684
Python
Python (3.8.2)
py
Runtime Error
243
19352
3415
import sys from collections import deque sys.setrecursionlimit(100000) input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [0]*v self.iter = [0]*v def add_edge(self, fr...
s465484483
p02561
u021548497
1599581082
Python
PyPy3 (7.3.0)
py
Runtime Error
250
78376
3329
import sys from collections import deque sys.setrecursionlimit(100000) input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [0]*v self.iter = [0]*v def add_edge(self, fr...
s852023386
p02561
u021548497
1599579797
Python
PyPy3 (7.3.0)
py
Runtime Error
394
87324
3169
import sys from collections import deque input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [0]*v self.iter = [0]*v def add_edge(self, fr, to, cap): self.graph...
s004159309
p02561
u021548497
1599579572
Python
PyPy3 (7.3.0)
py
Runtime Error
387
87236
3167
import sys from collections import deque input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [0]*v self.iter = [0]*v def add_edge(self, fr, to, cap): self.graph...
s396177217
p02561
u401686269
1599579106
Python
Python (3.8.2)
py
Runtime Error
655
68132
1279
import networkx as nx def main(): N,M=map(int,input().split()) S = [list(input()) for _ in range(N)] if N == M == 1: print(0) print(S[0][0]) exit() index = lambda i,j: i*M+j G=nx.Graph() dx,dy=(1,0),(0,1) E = [] n1,n2 = [],[] for i in range(N): for j in range(M): if S[i][j]==...
s981136737
p02561
u021548497
1599578983
Python
PyPy3 (7.3.0)
py
Runtime Error
5518
168904
3279
import sys from collections import deque input = sys.stdin.readline class Dinic: def __init__(self, v): self.vertice = v self.inf = int(1e9) self.graph = [[] for i in range(v)] self.level = [[] for i in range(v)] self.iter = [[] for i in range(v)] def add_edge(self...
s306114386
p02561
u401686269
1599578144
Python
Python (3.8.2)
py
Runtime Error
30
9028
1410
import networkx as nx def main(): N,M=map(int,input().split()) S = [list(input()) for _ in range(N)] if N == M == 1: print(0) print(S[0][0]) exit() index = lambda i,j: i*M+j G=nx.DiGraph() G.add_node('source') G.add_node('sink') dx,dy=(1,0),(0,1) E = [] for i in range(N): for j i...
s868964877
p02561
u401686269
1599576775
Python
Python (3.8.2)
py
Runtime Error
5220
116816
1407
import networkx as nx def main(): N,M=map(int,input().split()) S = [list(input()) for _ in range(N)] if N == M == 1: print(0) print(S[0][0]) exit() index = lambda i,j: i*M+j G=nx.DiGraph() G.add_node('source') G.add_node('sink') dx,dy=(1,0),(0,1) for i in range(N): for j in range(M...
s631363706
p02561
u401686269
1599576698
Python
Python (3.8.2)
py
Runtime Error
424
69952
1405
import networkx as nx def main(): N,M=map(int,input().split()) S = [list(input()) for _ in range(N)] if N == M == 1: print(0) print(S[0][0]) exit() index = lambda i,j: i*M+j G=nx.DiGraph() G.add_node('source') G.add_node('sink') dx,dy=(1,0),(0,1) for i in range(N): for j in range(M...
s306366660
p02561
u401686269
1599575829
Python
Python (3.8.2)
py
Runtime Error
5318
116464
1195
import networkx as nx N,M=map(int,input().split()) S = [input() for _ in range(N)] index = lambda i,j: i*M+j G=nx.DiGraph() dx,dy=(1,0),(0,1) for i in range(N): for j in range(M): if S[i][j]=='#':continue if (i+j) %2: G.add_edge(index(i,j),'sink',capacity=1) else: G.add_edge('source',index(...
s038234772
p02561
u021548497
1599575701
Python
PyPy3 (7.3.0)
py
Runtime Error
5521
185908
2924
import sys input = sys.stdin.readline class FordFulkerson: def __init__(self, n): self.n = n self.graph = [[] for _ in range(n)] self.ans = dict() #二頂点間を結ぶ経路の追加 def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, cap, for...
s712395669
p02561
u401686269
1599575540
Python
Python (3.8.2)
py
Runtime Error
5231
116852
1185
import networkx as nx N,M=map(int,input().split()) S = [input() for _ in range(N)] index = lambda i,j: i*M+j G=nx.DiGraph() dx,dy=(1,0),(0,1) for i in range(N): for j in range(M): if S[i][j]=='#':continue if (i+j) %2: G.add_edge(index(i,j),'sink',capacity=1) else: G.add_edge('source',index(...
s662975574
p02561
u021548497
1599561975
Python
PyPy3 (7.3.0)
py
Runtime Error
5521
184464
3080
import sys input = sys.stdin.readline class FordFulkerson: def __init__(self, n): self.n = n self.graph = [[] for _ in range(n)] self.ans = dict() #二頂点間を結ぶ経路の追加 def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, cap, for...
s920252431
p02561
u368780724
1599551997
Python
PyPy3 (7.3.0)
py
Runtime Error
325
83400
3140
import sys readline = sys.stdin.readline import collections class Dinic: def __init__(self, vnum): self.edge = [[] for i in range(vnum)] self.n = vnum # infはint型の方が良いかもね self.inf = float('inf') def addedge(self, st, en, c): self.edge[st].append([en, c, len(self.edge[en])]...
s550320202
p02562
u415718506
1600626441
Python
Python (3.8.2)
py
Runtime Error
25
9072
924
# https://atcoder.jp/contests/practice2/tasks/practice2_e import sys from atcoder.mincostflow import MCFGraph def main() -> None: n, k = map(int, sys.stdin.readline().split()) s = n * 2 t = s + 1 g = MCFGraph(t + 1) grid = [list(map(int, sys.stdin.readline().split())) for _ in range(n)] big ...
s085579817
p02562
u588341295
1599818697
Python
PyPy3 (7.3.0)
py
Runtime Error
5516
98584
3822
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): retu...
s987579226
p02562
u968846084
1599812935
Python
Python (3.8.2)
py
Runtime Error
286
104280
560
import numpy as np n,m=map(int,input().split()) mod=998244353 f = np.array([0]*(2**19)) g = np.array([0]*(2**19)) f[0:n]=list(map(int,input().split())) g[0:m]=list(map(int,input().split())) fft_len = 2**20 # |f|+|g|-1 以上の2の冪数 # f,gをフーリエ変換 Ff = np.fft.rfft(f, fft_len) #print(Ff) Fg = np.fft.rfft(g, fft_len) #print(F...
s222050273
p02562
u535803878
1599604031
Python
PyPy3 (7.3.0)
py
Runtime Error
100
68884
980
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,k = list(map(int, input().split())) a = [list(map(int, input().split())) for _ in range(n)] import networkx as nx ans = (-float("inf"), None) for f in range(1,n*k+1): g = ...
s665452997
p02563
u730769327
1600712915
Python
PyPy3 (7.3.0)
py
Runtime Error
88
68712
459
import numpy as np def convolve(f,g): f=np.array(f,np.int64) g=np.array(g,np.int64) fft_len=1 while 2*fft_len<len(f)+len(g)-1: fft_len*=2 fft_len*=2 Ff=np.fft.rfft(f,fft_len) Fg=np.fft.rfft(g,fft_len) Fh=Ff*Fg h=np.fft.irfft(Fh,fft_len) h=np.rint(h).astype(np.int64)%mod return h[:len(f)+l...
s511121201
p02563
u562016607
1600627425
Python
Python (3.8.2)
py
Runtime Error
1562
148264
320
import numpy as np N,M=map(int,input().split()) a=[int(i) for i in input().split()] b=[int(i) for i in input().split()] K=1<<20 A=np.zeros(K) B=np.zeros(K) for i in range(N): A[i]=a[i] B[i]=b[i] C=np.fft.ifft(np.fft.fft(B)*np.fft.fft(A)) mod=998244353 ans=[int(i+0.5)%mod for i in np.real(C)][:N+M-1] print(*ans)
s078042593
p02563
u828706986
1600608819
Python
Python (3.8.2)
py
Runtime Error
2248
361768
12257
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s472860440
p02563
u828706986
1600608764
Python
Python (3.8.2)
py
Runtime Error
2259
361640
12230
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s288841989
p02563
u828706986
1600608048
Python
Python (3.8.2)
py
Runtime Error
39
10712
12160
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s825515876
p02563
u073852194
1600510339
Python
PyPy3 (7.3.0)
py
Runtime Error
331
183732
3056
#Convolution_998244353 MOD = 998244353 ROOT = 3 sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497, 0, 0, 0, 0, 0, 0, 0, 0, 0) sum_...
s643307031
p02563
u073852194
1600508859
Python
PyPy3 (7.3.0)
py
Runtime Error
459
179484
4724
MOD = 998244353 ROOT = 3 class Convolution_998244353(): def __init__(self): self.first1 = True self.first2 = True self.sum_e = [0] * 30 self.sum_ie = [0] * 30 def inv_gcd(self, a, b): a %= b if a == 0: return b, 0 s = b t = a m0 = 0 ...
s304831139
p02563
u073852194
1600508794
Python
PyPy3 (7.3.0)
py
Runtime Error
458
179280
4747
MOD = 998244353 ROOT = 3 class Convolution_998244353(): def __init__(self): self.first1 = True self.first2 = True self.sum_e = [0] * 30 self.sum_ie = [0] * 30 def inv_gcd(self, a, b): a %= b if a == 0: return b, 0 s = b t = a m0 = 0 ...
s686856959
p02563
u456353530
1600081981
Python
PyPy3 (7.3.0)
py
Runtime Error
91
68616
3935
import numpy as np from numpy.fft import fft from numpy.fft import ifft class Convolution: def __init__(s, MOD): s.MOD = MOD s.PrimitiveRoot = s.primitive_root(MOD) s._BIT_TABLE = [0] * 64 _BIT_HASH = 0x03F566ED27179461 for i in range(64): s._BIT_TABLE[_BIT_HASH >> 58] = i _BIT_HAS...
s704913290
p02563
u456353530
1600076736
Python
PyPy3 (7.3.0)
py
Runtime Error
87
68632
5644
import numpy as np from numpy.fft import fft from numpy.fft import ifft _BIT_TABLE = [0] * 64 _BIT_HASH = 0x03F566ED27179461 for i in range(64): _BIT_TABLE[_BIT_HASH >> 58] = i _BIT_HASH <<= 1 _BIT_HASH &= 0xFFFFFFFFFFFFFFFF def convolution(a, b, MOD): ModInt.set_mod(MOD) Primitive_Root = primitive_root(MOD...
s601015250
p02563
u754022296
1600073696
Python
PyPy3 (7.3.0)
py
Runtime Error
96
68668
1325
mod = 1012924417 primitive_root = 5 roots = [pow(primitive_root, (mod-1)>>i, mod) for i in range(22)] inv_roots = [pow(root, mod-2, mod) for root in roots] def ntt(A, n): for i in range(n): m = 1<<(n-i-1) for s in range(1<<i): w = 1 s *= m*2 for j in range(m): ...
s656713061
p02563
u456353530
1600022603
Python
Python (3.8.2)
py
Runtime Error
119
27168
5162
import numpy as np from numpy.fft import fft from numpy.fft import ifft import sympy _BIT_TABLE = [0] * 64 _BIT_HASH = 0x03F566ED27179461 for i in range(64): _BIT_TABLE[_BIT_HASH >> 58] = i _BIT_HASH <<= 1 _BIT_HASH &= 0xFFFFFFFFFFFFFFFF def convolution(a, b, MOD): ModInt.set_mod(MOD) n, m = len(a), len(b) ...
s569703092
p02563
u960080897
1599832397
Python
PyPy3 (7.3.0)
py
Runtime Error
366
201980
7597
# 動作テスト # ACならAtCoder LibraryのPython版Convolution翻訳完了 class convolution: def __init__(self, a: list, b: list, mod: int): self.a, self.b = a, b self.n, self.m = len(a), len(b) self.MOD = mod self.g = self.__primitive_root_constexpr() def convolution(self) -> list: n, ...
s285426846
p02563
u968846084
1599812830
Python
Python (3.8.2)
py
Runtime Error
459
100148
557
import numpy as np n,m=map(int,input().split()) mod=998244353 f = np.array([0]*(2**19)) g = np.array([0]*(2**19)) f[0:n]=list(map(int,input().split())) g[0:m]=list(map(int,input().split())) fft_len = 20 # |f|+|g|-1 以上の2の冪数 # f,gをフーリエ変換 Ff = np.fft.rfft(f, fft_len) #print(Ff) Fg = np.fft.rfft(g, fft_len) #print(Fg) ...
s557177958
p02563
u960080897
1599807692
Python
Python (3.8.2)
py
Runtime Error
1535
264688
11572
# Date [ 2020-09-11 01:37:51 ] # Problem [ f.py ] # Author Koki_tkg # とりあえずpythonに変換したけどバグだらけw # 今の自分の力量ではここら辺が限界かも...後は上級者の翻訳待ち # convolution.py def butterfly(a: list): n = len(a) h = ceil_pow2(n) g = primitive_root(Mint.mod()) first = True sum_e = [0] * 30 if first: first = False...
s632580256
p02563
u960080897
1599781973
Python
Python (3.8.2)
py
Runtime Error
1525
264588
11607
# Date [ 2020-09-11 01:37:51 ] # Problem [ f.py ] # Author Koki_tkg # とりあえずpythonに変換したけどバグだらけw # 今の自分の力量ではここら辺が限界かも...後は上級者の翻訳待ち # convolution.py def butterfly(a: list): n = len(a) h = ceil_pow2(n) g = primitive_root(Mint.mod()) first = True sum_e = [Mint()] * 30 if first: first = ...
s281101383
p02563
u519339498
1599547987
Python
PyPy3 (7.3.0)
py
Runtime Error
99
68420
283
import numpy as np import sys pin=sys.stdin.readline pout=sys.stdout.write N,M=map(int,pin().split()) a=list(map(int,pin().split())) arr1=np.array(a) b=list(map(int,pin().split())) arr2=np.array(b) c=np.convolve(arr1,arr2) for i in range(N+M-1): pout(f"{c[i]%998244353} ") print()
s344612489
p02563
u910632349
1599523433
Python
PyPy3 (7.3.0)
py
Runtime Error
388
68252
225
import numpy as np n,m=map(int,input().split()) a=np.array(list(map(int,input().split())),dtype='uint64') b=np.array(list(map(int,input().split())),dtype='uint64') c=np.convolve(a,b) for i in c: print(i%998244353,end=" ")
s512752962
p02564
u034128150
1600723109
Python
PyPy3 (7.3.0)
py
Runtime Error
340
212752
2717
import sys class csr: def __init__(self, N, edges): self.start = [0]*(N+1) self.elist = [0]*len(edges) for e in edges: self.start[e[0]+1] += 1 for i in range(1, N+1): self.start[i] += self.start[i-1] counter = self.start[:] for e in edges: ...
s023764169
p02564
u201928947
1600647727
Python
PyPy3 (7.3.0)
py
Runtime Error
249
172428
2698
from collections import deque class csr: def __init__(self,N,edges): self.start = [0]*(N+1) self.elist = [0]*len(edges) for e in edges: self.start[e[0]+1] += 1 for i in range(1,N+1): self.start[i] += self.start[i-1] counter = self.start[:] for...
s125992929
p02564
u201928947
1600647526
Python
PyPy3 (7.3.0)
py
Runtime Error
527
172380
2717
from collections import deque class csr: def __init__(self,N,edges): self.start = [0]*(N+1) self.elist = [0]*len(edges) for e in edges: self.start[e[0]+1] += 1 for i in range(1,N+1): self.start[i] += self.start[i-1] counter = self.start[:] for...
s752013601
p02564
u201928947
1600647262
Python
PyPy3 (7.3.0)
py
Runtime Error
3472
426300
2745
from collections import deque class csr: def __init__(self,N,edges): self.start = [0]*(N+1) self.elist = [0]*len(edges) for e in edges: self.start[e[0]+1] += 1 for i in range(1,N+1): self.start[i] += self.start[i-1] counter = self.start[:] for...
s265194026
p02564
u925782032
1600632457
Python
PyPy2 (7.3.0)
py
Runtime Error
63
63396
1116
import sys range = xrange input = raw_input def find_SCC(coupl): SCC, S, P = [], [], [] depth = [0] * len(coupl) stack = list(range(len(coupl))) while stack: node = stack.pop() if node < 0: d = depth[~node] - 1 if P[-1] > d: SCC.append(S[d:]) ...
s216378653
p02564
u208713671
1600555838
Python
PyPy3 (7.3.0)
py
Runtime Error
2968
331544
1248
def scc(N, G, RG): order = [] used = [0]*N group = [None]*N def dfs(s): used[s] = 1 for t in G[s]: if not used[t]: dfs(t) order.append(s) def rdfs(s, col): group[s] = col used[s] = 1 for t in RG[s]: if not used[t...
s181493402
p02564
u102461423
1600536603
Python
Python (3.8.2)
py
Runtime Error
730
176972
2917
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8), cache=True) def scc_dfs(N, G, idx, low, ord, ids, vi...
s744573529
p02564
u102461423
1600536573
Python
Python (3.8.2)
py
Runtime Error
712
177252
2869
import sys import numpy as np import numba from numba import njit, b1, i4, i8, f8 read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines @njit((i8, i8[:, :], i8[:], i8[:], i8[:], i8[:], i8[:], i8, i8, i8, i8), cache=True) def scc_dfs(N, G, idx, low, ord, ids, vi...
s588524496
p02564
u828706986
1600515613
Python
Python (3.8.2)
py
Runtime Error
3441
173016
4083
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__scc_code = """ import copy import typing class CSR: def __init__( self, n: int, edges: typing.List[typing.Tuple[int, in...
s485324651
p02564
u630211216
1600493297
Python
Python (3.8.2)
py
Runtime Error
25
8980
587
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll=long long; using Graph=vector<vector<int>>; using pp=pair<ll,pair<ll,ll>>; #define MAX 1000000 #define MOD 1000000007 #define INF 1000000000000000000 int main(){ int N,M; cin>>N>>M; scc_graph G(N); for(int i=...
s296289758
p02564
u325227960
1600476000
Python
PyPy3 (7.3.0)
py
Runtime Error
2852
321572
1321
import sys input = sys.stdin.readline n, m = map(int,input().split()) C = [list(map(int,input().split())) for i in range(m)] def dfs_numbering(i, M, V, ANS, cnt, v): V[i] = v for x in M[i]: if V[x] == -1: cnt = dfs_numbering(x, M, V, ANS, cnt, v) ANS[i] = cnt return cnt + 1 class ...
s079368987
p02564
u334712262
1600444852
Python
PyPy3 (7.3.0)
py
Runtime Error
2195
370564
1497
from collections import defaultdict def scc(g): rg = defaultdict(list) V = set() for u, e in g.items(): V.add(u) for v in e: V.add(v) rg[v].append(u) o = [] done = set() def dfs(u): done.add(u) for v in g[u]: if v in done: ...
s355105139
p02564
u141610915
1600045473
Python
PyPy3 (7.3.0)
py
Runtime Error
2107
315580
1472
import sys input = sys.stdin.readline N, M = map(int, input().split()) class StrongConnections: def __init__(self, n, root = None): self.n = n self.root = root self.e = [[] for _ in range(n + 1)] self.re = [[] for _ in range(n + 1)] def add_edge(self, fr, to): self.e[fr].append(to) self.re[...
s412046333
p02564
u520276780
1599864705
Python
PyPy3 (7.3.0)
py
Runtime Error
2449
275720
773
n,m=map(int, input().split()) e=[[] for _ in range(n)] e_rev=[[] for _ in range(n)] for i in range(m): ai,bi=map(int, input().split()) e[ai].append(bi) e_rev[bi].append(ai) p_ord=[] used=[0]*n def dfs(v): used[v]=1 for u in e[v]: if not used[u]: dfs(u) p_ord.append(v) for i ...
s609903311
p02564
u520276780
1599864527
Python
PyPy3 (7.3.0)
py
Runtime Error
2106
261400
746
n,m=map(int, input().split()) e=[[] for _ in range(n)] e_rev=[[] for _ in range(n)] for i in range(m): ai,bi=map(int, input().split()) e[ai].append(bi) e_rev[bi].append(ai) p_ord=[] used=[0]*n def dfs(v): used[v]=1 for u in e[v]: if not used[u]: dfs(u) p_ord.append(v) for i ...
s610030460
p02564
u520276780
1599864303
Python
Python (3.8.2)
py
Runtime Error
3983
235184
731
n,m=map(int, input().split()) e=[[] for _ in range(n)] e_rev=[[] for _ in range(n)] for i in range(m): ai,bi=map(int, input().split()) e[ai].append(bi) e_rev[bi].append(ai) p_ord=[] used=[0]*n def dfs(v): used[v]=1 for u in e[v]: if not used[u]: dfs(u) p_ord.append(v) for i ...
s711382285
p02564
u520276780
1599862735
Python
PyPy3 (7.3.0)
py
Runtime Error
2308
261376
730
n,m=map(int, input().split()) e=[[] for _ in range(n)] e_rev=[[] for _ in range(n)] for i in range(m): ai,bi=map(int, input().split()) e[ai].append(bi) e_rev[bi].append(ai) p_ord=[] used=[0]*n def dfs(v): used[v]=1 for u in e[v]: if not used[u]: dfs(u) p_ord.append(v) for i ...
s135156995
p02564
u520276780
1599862639
Python
PyPy3 (7.3.0)
py
Runtime Error
2391
261092
732
n,m=map(int, input().split()) e=[[] for _ in range(n)] e_rev=[[] for _ in range(n)] for i in range(m): ai,bi=map(int, input().split()) e[ai].append(bi) e_rev[bi].append(ai) p_ord=[] used=[0]*n def dfs(v): used[v]=1 for u in e[v]: if not used[u]: dfs(u) p_ord.append(v) for i ...
s881570245
p02564
u606045429
1599794190
Python
Python (3.8.2)
py
Runtime Error
1618
167812
374
from scipy.sparse.csgraph import connected_components from scipy.sparse import csr_matrix N, M, *AB = map(int, open(0).read().split()) G = csr_matrix(([1] * M, (AB[::2], AB[1::2]))) K, labels = connected_components(G, connection='strong') C = [[] for _ in range(K)] for i, l in enumerate(labels): C[l].append(i) ...
s726574109
p02564
u606045429
1599793751
Python
Python (3.8.2)
py
Runtime Error
1585
168196
362
from scipy.sparse.csgraph import connected_components from scipy.sparse import csr_matrix N, M, *AB = map(int, open(0).read().split()) G = csr_matrix(([1] * M, (AB[::2], AB[1::2]))) K, labels = connected_components(G, connection='strong') C = [[] for _ in range(K)] for i, l in enumerate(labels): C[l].append(i) ...
s060051666
p02564
u488401358
1599772583
Python
PyPy3 (7.3.0)
py
Runtime Error
1852
252720
1044
import sys input = sys.stdin.readline sys.setrecursionlimit(5*10**5) N,M = map(int,input().split()) edge = [[] for i in range(M)] rev_edge = [[] for i in range(M)] for _ in range(M): a,b = map(int,input().split()) edge[a].append(b) rev_edge[b].append(a) seen = [False]*N stop = [] def dfs(v): for nv...
s049798100
p02564
u873915460
1599742802
Python
PyPy3 (7.3.0)
py
Runtime Error
2025
285588
807
def SCC(G): D=[] C=[len(G)-1] U=[1]*len(G) def DFS(x): if U[x]: U[x]=0 for i in range(len(G[x])): DFS(G[x][i]) D.append(x) for i in range(len(G)): if U[i]: DFS(i) GR=[[] for i in range(len(G))] for i in range(N): for j in range(len(G[i])): GR[G[i][j]].a...
s948327408
p02564
u119148115
1599685773
Python
PyPy3 (7.3.0)
py
Runtime Error
1901
267268
1417
import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) class SCC: def __init__(self,N): self.N = N self.graph = [[] for _ in range(N)] self.graph_rev = [[] for _ in range(N)] self.flag = [False]*N def add_edge(self,start,end): if start == end: ...
s639253758
p02564
u456353530
1599668373
Python
Python (3.8.2)
py
Runtime Error
5262
278944
2522
#-------最強ライブラリSCC(Python)------ #卍分解卍 #出力例は辺の順が逆!ずるい! import copy class csr: # start 頂点iまでの頂点が、矢元として現れた回数 # elist 矢先のリストを矢元の昇順にしたもの def __init__(s, n, edges): s.start = [0] * (n + 1) s.elist = [[] for _ in range(len(edges))] for e in edges: s.start[e[0] + 1] += 1 for i in range(1, n + 1): ...
s613894826
p02564
u401686269
1599661394
Python
PyPy3 (7.3.0)
py
Runtime Error
5527
560152
2299
class UnionFind(): def __init__(self, n=0): self.d = [-1]*n def find(self, x): if self.d[x] < 0: return x self.d[x] = self.find(self.d[x]) return self.d[x] def unite(self, x, y): x,y=self.find(x),self.find(y) if x==y:return False if self.d[x] > s...
s067784884
p02564
u401686269
1599660996
Python
Python (3.8.2)
py
Runtime Error
5520
281260
2283
class UnionFind(): def __init__(self, n=0): self.d = [-1]*n def find(self, x): if self.d[x] < 0: return x self.d[x] = self.find(self.d[x]) return self.d[x] def unite(self, x, y): x,y=self.find(x),self.find(y) if x==y:return False if self.d[x] > s...
s648194776
p02564
u183395797
1599627914
Python
Python (3.8.2)
py
Runtime Error
4554
624508
395
import networkx as nx N, M = [int(x) for x in input().split()] edges = [[int(x) for x in input().split()] for i in range(M)] graph = nx.DiGraph(edges) if True: import matplotlib.pyplot as plt nx.draw_networkx(graph) plt.show() SCC = list( nx.algorithms.components.strongly_connected_components(graph...
s593137226
p02564
u183395797
1599627897
Python
Python (3.8.2)
py
Runtime Error
4557
624572
395
import networkx as nx N, M = [int(x) for x in input().split()] edges = [[int(x) for x in input().split()] for i in range(M)] graph = nx.DiGraph(edges) if True: import matplotlib.pyplot as plt nx.draw_networkx(graph) plt.show() SCC = list( nx.algorithms.components.strongly_connected_components(graph...
s715894169
p02564
u183395797
1599627330
Python
Python (3.8.2)
py
Runtime Error
5534
769688
304
import networkx N, M = [int(x) for x in input().split()] edges = [[int(x) for x in input().split()] for i in range(M)] graph = networkx.DiGraph(edges) SCC = list(networkx.algorithms.components.strongly_connected_components_recursive(graph)) print(len(SCC)) for comp in SCC: print(len(comp), *comp)
s003172449
p02564
u021548497
1599600533
Python
PyPy3 (7.3.0)
py
Runtime Error
88
68584
1618
import sys input = sys.stdin.readline() sys.setrecursionlimit(1000000) class SCC: def __init__(self, n): self.n = n self.graph = [[] for _ in range(n)] self.graph_rev = [[] for _ in range(n)] self.already = [False]*n def add_edge(self, fr, to): if fr == to: ...
s650007307
p02564
u021548497
1599600525
Python
Python (3.8.2)
py
Runtime Error
27
9268
1618
import sys input = sys.stdin.readline() sys.setrecursionlimit(1000000) class SCC: def __init__(self, n): self.n = n self.graph = [[] for _ in range(n)] self.graph_rev = [[] for _ in range(n)] self.already = [False]*n def add_edge(self, fr, to): if fr == to: ...
s538913157
p02564
u021548497
1599599977
Python
Python (3.8.2)
py
Runtime Error
3523
200088
1554
class SCC: def __init__(self, n): self.n = n self.graph = [[] for _ in range(n)] self.graph_rev = [[] for _ in range(n)] self.already = [False]*n def add_edge(self, fr, to): if fr == to: return self.graph[fr].append(to) self.graph_rev[to]....
s020560961
p02565
u298682635
1599921721
Python
Python (3.8.2)
py
Runtime Error
517
29500
410
n,d = (int(x) for x in input().split()) lists = [[] for i in range(n)] for j in range(n): lists[j] = list(map(int,input().split())) c = 1 for i in range(n): c *= i+1 dists = [] for i in range(n-1): for j in range(i+1,n): dist = ( (lists[i][0] -lists[j][0]) + (lists[i][1]-lists[j][1]) )**2 dists.append...
s415137699
p02565
u606045429
1599771746
Python
Python (3.8.2)
py
Runtime Error
770
38656
1111
from scipy.sparse.csgraph import connected_components from scipy.sparse import csr_matrix N, D, *XY = map(int, open(0).read().split()) XY = list(zip(*[iter(XY)] * 2)) R, C = [], [] for i, (x1, y1) in enumerate(XY): for j, (x2, y2) in enumerate(XY): if i == j: continue if abs(x1 - x2) ...
s286714029
p02565
u183395797
1599646308
Python
Python (3.8.2)
py
Runtime Error
921
55960
1291
import networkx as nx import io import os input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline N, D = [int(x) for x in input().split()] XY = [[int(x) for x in input().split()] for i in range(N)] graph = nx.DiGraph() # a_i = 0 means choose x, a_i = 1 means choose y # Store i for a_i==0 and i+N for a_i==1...
s486254150
p02565
u535803878
1599608634
Python
PyPy3 (7.3.0)
py
Runtime Error
179
71248
3612
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,d = list(map(int, input().split())) xy = [tuple(map(int, input().split())) for _ in range(n)] class SAT2: def __init__(self, n): self.n = n self.ns = [[] ...
s082114395
p02566
u401686269
1600613935
Python
Python (3.8.2)
py
Runtime Error
5474
3480376
627
def calc_lcp(s1,s2): count=0 for i in range(min(len(s1), len(s2))): if s1[i] == s2[i]: count += 1 else: break return count def suffix_array(s,output_sa=True,output_lcp=True): sa = sorted([(i,s[i:]) for i in range(len(s))], key=lambda x: x[1]) if output_sa and not output_lcp: return ...
s386866202
p02566
u401686269
1600613881
Python
Python (3.8.2)
py
Runtime Error
5467
3485060
666
def calc_lcp(s1,s2): count=0 for i in range(min(len(s1), len(s2))): if s1[i] == s2[i]: count += 1 else: break return count def suffix_array(s,output_sa=True,output_lcp=True): #sa = sorted([(i,s[i:]) for i in range(len(s))], key=lambda x: x[1]) sa = [(i,s[i:]) for i in range(len(s))]...
s201823578
p02566
u401686269
1600613515
Python
Python (3.8.2)
py
Runtime Error
3905
3480556
621
def calc_lcp(s1,s2): count=0 for i in range(min(len(s1), len(s2))): if s1[i] == s2[i]: count += 1 else: break return count def suffix_array(s,output_sa=True,output_lcp=True): sa = sorted([(i,s[i:]) for i in range(len(s))], key=lambda x: x[1]) if output_sa and not output_lcp: return ...
s661805526
p02566
u401686269
1600613139
Python
PyPy3 (7.3.0)
py
Runtime Error
2855
3485360
434
def calc_lcp(s1,s2): count=0 for i in range(min(len(s1), len(s2))): if s1[i] == s2[i]: count += 1 else: break return count def suffix_array(s, lcp=True): sa = sorted([(i,s[i:]) for i in range(len(s))], key=lambda x: x[1]) if lcp: return sa,[calc_lcp(sa[i-1][1], sa[i][1]) for i in ra...
s014684702
p02566
u401686269
1600612913
Python
Python (3.8.2)
py
Runtime Error
5310
3485100
435
def calc_lcp(s1,s2): count=0 for i in range(min(len(s1), len(s2))): if s1[i] == s2[i]: count += 1 else: break return count def suffix_array(s, lcp=True): sa = sorted([(i,s[i:]) for i in range(len(s))], key=lambda x: x[1]) if lcp: return sa,[calc_lcp(sa[i-1][1], sa[i][1]) for i in ra...
s829981797
p02566
u785989355
1600382815
Python
Python (3.8.2)
py
Runtime Error
32
9564
2476
code = """ # distutils: language=c++ # distutils: include_dirs=[/home/USERNAME/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl] # cython: boundscheck=False # cython: wraparound=False from libcpp.string cimport string from libcpp.vector cimport vector from libc.stdio cimport getchar, printf cd...
s477754167
p02566
u914693053
1599917552
Python
Python (3.8.2)
py
Runtime Error
28
8840
291
def printAllSubstrings(s, n): c=0 for i in range(n):         temp=""         for j in range(i,n):             temp+=s[j]             c+=1 print(c)    # Driver program to test above function    s = input() AllSubstrings(s, len(s))
s037488388
p02566
u234680893
1599917084
Python
Python (3.8.2)
py
Runtime Error
27
8896
308
def printAllSubstrings(s, n): # Fix start index in outer c=0 for i in range(n): temp="" for j in range(i,n): temp+=s[j] c+=1 print(c) # Driver program to test above function s = input() printAllSubstrings(s, len(s))
s275596662
p02566
u960080897
1599679413
Python
Python (3.8.2)
py
Runtime Error
751
56176
6891
# Date [ 2020-09-09 19:51:26 ] # Problem [ i.py ] # Author Koki_tkg import sys # import math # import bisect # import numpy as np # from decimal import Decimal # from numba import njit, i8, u1, b1 #JIT compiler # from itertools import combinations, product # from collections import Counter, deque, defaultdict # sys.s...
s355178345
p02567
u730769327
1600616221
Python
PyPy3 (7.3.0)
py
Runtime Error
928
111592
1275
def segfunc(x,y):return max(x,y) ide_ele=0 class segtree(): def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele): n=len(init_val) self.segfunc=segfunc self.ide_ele=ide_ele self.num=1<<(n-1).bit_length() self.tree=[ide_ele]*2*self.num for i in range(n): self.tree[self.num+i]=init_v...
s984232215
p02567
u730769327
1600615855
Python
PyPy3 (7.3.0)
py
Runtime Error
936
109900
1271
def segfunc(x,y):return max(x,y) ide_ele=0 class segtree(): def __init__(self,init_val,segfunc=segfunc,ide_ele=ide_ele): n=len(init_val) self.segfunc=segfunc self.ide_ele=ide_ele self.num=1<<(n-1).bit_length() self.tree=[ide_ele]*2*self.num for i in range(n): self.tree[self.num+i]=init_v...
s154448006
p02567
u828706986
1600552566
Python
Python (3.8.2)
py
Runtime Error
1760
32616
4744
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s453557173
p02567
u828706986
1600548862
Python
Python (3.8.2)
py
Runtime Error
1711
32804
4680
import types _atcoder_code = """ # Python port of AtCoder Library. __version__ = '0.0.1' """ atcoder = types.ModuleType('atcoder') exec(_atcoder_code, atcoder.__dict__) _atcoder__bit_code = """ def _ceil_pow2(n: int) -> int: x = 0 while (1 << x) < n: x += 1 return x def _bsf(n: int) -> int: ...
s260850236
p02567
u077291787
1600525079
Python
PyPy3 (7.3.0)
py
Runtime Error
194
127396
5763
from typing import Callable, Iterator, TypeVar S = TypeVar("S") class SegmentTree: """Segment Tree References: https://github.com/atcoder/ac-library/blob/master/atcoder/segtree.hpp """ __slots__ = ["_e", "_op", "_n", "_size", "_tree"] def __init__(self, a: Iterator[S], n: int, e: S, op:...