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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s063069167 | p02557 | u456910011 | 1600026605 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8956 | 2557 | /*
_ _
| |__ | |__ __ _ __ _ _ _ __ _
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
|___/ |___/
*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#... |
s306736426 | p02557 | u667084803 | 1600026547 | Python | PyPy3 (7.3.0) | py | Runtime Error | 300 | 171868 | 269 | from collections import Counter, deque
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_cn = Counter(A)
B_cn = Counter(B)
AB_cn = Counter(A+B)
if AB_cn.most_common()[0][1] > 2*N:
print("No")
else:
print("Yes")
0/0
|
s052263086 | p02557 | u867320886 | 1600026520 | Python | Python (3.8.2) | py | Runtime Error | 712 | 81588 | 812 | import sys
from collections import Counter
import heapq
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a_count = Counter(a)
b_count = Counter(b)
for i in a_count.keys():
if a_count[i] + b_count[i] > n:
print("No")
sys.exit()
b_can = []
for k,v in b_count.i... |
s243098192 | p02557 | u723792785 | 1600026301 | Python | PyPy3 (7.3.0) | py | Runtime Error | 217 | 156864 | 515 | from collections import Counter
n = int(input())
a = list(map(int,input().split()))
ac = Counter(a)
b = list(map(int,input().split()))
bc = Counter(b)
mode = 1
for i in range(n):
if ac[i] > n - bc[i]:
mode = 0
break
if mode:
print("Yes")
b.reverse()
ansl = [0 for _ in range(n)]
i = 0
while i < n:
if a[i] ... |
s831507353 | p02557 | u111365362 | 1600026214 | Python | PyPy3 (7.3.0) | py | Runtime Error | 160 | 126780 | 583 | n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.reverse()
c = []
cs = -1
for i in range(n):
if a[i] > b[i]:
c.append(1)
elif a[i] == b[i]:
c.append(0)
e = a[i]
if cs == -1:
cs = i
else:
c.append(-1)
#print(a)
#print(b)
#print(c)
ans = 0
for i in r... |
s023408102 | p02557 | u102461423 | 1600025765 | Python | Python (3.8.2) | py | Runtime Error | 232 | 49092 | 1370 | import sys
from heapq import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
countA[x] += 1
for x ... |
s574137566 | p02557 | u969708690 | 1600025520 | Python | Python (3.8.2) | py | Runtime Error | 321 | 59484 | 487 | import collections
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
L=A+B
c = collections.Counter(L)
for i in c:
if c[i]>N:
print("No")
exit()
c = collections.Counter(B)
K=list(c)
M=dict(c)
ans=list()
for i in range(N):
if A[i]==K[-1]:
ans.append(K[-2])
M[K[-2]]-=1
... |
s350489124 | p02557 | u102461423 | 1600025303 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 174472 | 1355 | import sys
from heapq import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
countA[x] += 1
for x ... |
s115834967 | p02557 | u102461423 | 1600025242 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 164980 | 1271 | import sys
from heapq import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
countA[x] += 1
for x ... |
s568614117 | p02557 | u102461423 | 1600025171 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 163548 | 1271 | import sys
from heapq import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
countA = [0] * (N + 1)
countB = [0] * (N + 1)
for x in A:
countA[x] += 1
for x ... |
s405465991 | p02557 | u873915460 | 1600024603 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2208 | 108124 | 502 | N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=[0]*N
D=[0]*N
for i in range(N):
C[A[i]-1]+=1
D[B[i]-1]+=1
E,F=max(C),max(D)
if min(E,F)>N//2 and C.index(E)==D.index(F):
print('No')
exit()
B=B[::-1]
U=[0]*N
for i in range(N):
if U[i]:
continue
if A[i]==B[i]:
j=i+1
... |
s413883470 | p02558 | u543954314 | 1600703964 | Python | Python (3.8.2) | py | Runtime Error | 22 | 8928 | 1499 | #![allow(unused_imports, non_snake_case, dead_code)]
use proconio::{
input, fastout,
marker::{Chars, Bytes, Usize1}
};
struct UnionFind {
size: usize,
pos: Vec<isize>,
}
impl UnionFind {
fn new(n: usize) -> Self {
let size = n;
let pos = vec![-1; n + 1];
UnionFind { size, po... |
s614527875 | p02558 | u095094246 | 1600563942 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9336 | 1800 | N, Q = map(int, input().split())
dsu = DSU(N)
for _ in range(Q):
t, u, v = map(int, input().split())
if t == 0:
# add line
dsu.merge(u, v)
else:
# concat
if dsu.same(u, v):
print(1)
else:
print(0)
import typing
class DSU:
'''
Implem... |
s109104563 | p02558 | u658655325 | 1600544035 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8932 | 356 | #include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
int main() {
int N, Q;
cin >> N >> Q;
dsu d(N);
for (int i = 0; i < Q; i++) {
int t, u, v;
cin >> t >> u >> v;
if (t) {
cout << d.same(u, v) << endl;
} else {
... |
s238984146 | p02558 | u077291787 | 1600308978 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 68636 | 915 | class UnionFind:
__slots__ = ["_data_size", "_roots"]
def __init__(self, data_size: int) -> None:
self._data_size = data_size
self._roots = [-1] * data_size
def __getitem__(self, x: int) -> int:
while self._roots[x] >= 0:
x = self._roots[x]
return x
def is_... |
s004825740 | p02558 | u034128150 | 1600283356 | Python | PyPy3 (7.3.0) | py | Runtime Error | 5564 | 2052640 | 4489 | # https://atcoder.jp/contests/practice2/submissions/16598132
# 上記のリンクの提出をいじらせてもらってます。
class mf_graph:
__slots__ = ["N", "graph", "capacities", "level", "it"]
def __init__(self, N):
self.N = N
self.graph = [[] for _ in range(N)]
self.capacities = [dict() for _ in range(N)]
def add... |
s953352516 | p02558 | u034128150 | 1600282850 | Python | PyPy3 (7.3.0) | py | Runtime Error | 5595 | 2017012 | 4544 | # import cProfile
# https://atcoder.jp/contests/practice2/submissions/16598132
# 上記のリンクの提出をいじらせてもらってます。
# from collections import deque
class mf_graph:
# __slots__ = ["N", "graph", "capacities", "level", "it"]
def __init__(self, N):
self.N = N
self.graph = [[] for _ in range(N)]
se... |
s874333383 | p02558 | u722217673 | 1600211172 | Python | PyPy3 (7.3.0) | py | Runtime Error | 123 | 90248 | 516 | import sys
def input(itr=iter(sys.stdin.readlines())): # pylint: disable= redefined-builtin
return next(itr).rstrip('\n\r')
###############################################################################
from networkx.utils.union_find import UnionFind
N, Q = map(int, input().split())
uf = UnionFind()
responses ... |
s952110197 | p02558 | u201234972 | 1600111286 | Python | Python (3.8.2) | py | Runtime Error | 216 | 39324 | 855 | import sys
input = sys.stdin.readline
def find(A,x):
p = A[x]
if p == x:
return x
a = find(A,p)
A[x] = a
return a
def union(A, x, y):
# bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。
if find(A,x) > find(A,y):
bx, by = find(A,y), find(A,x)
... |
s373503345 | p02558 | u187516587 | 1599994962 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 68660 | 1321 | def input():
return sys.stdin.readline()[:-1]
sys.setrecursionlimit(300000)
class uf:
def __init__(self,n):
self.n=n
self.l=[-1]*n
def ro(self,n): #root
if self.l[n]<0:
return n
r=self.ro(self.l[n])
self.l[n]=r
return r
def me(self,a,b)... |
s022664977 | p02558 | u729133443 | 1599991139 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9020 | 989 | code = r"""
# distutils: language=c++
# distutils: include_dirs=opt/atcoder-stl
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "<atcoder/dsu>" namespace "atcoder" nogil:
cdef cppclass dsu:
dsu(int n)
int merge(int a, int b)
bool same(int a, int b)
int lea... |
s855316686 | p02558 | u102655885 | 1599942730 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9024 | 1364 | class UnionFind:
def __init__(self, length):
self.parent_indexes = [-1]* length
def union(self, i, j):
if self.are_in_the_same_group(i, j):
return
# iが所属する集団のサイズ>=jが所属する集団のサイズにする
if self.get_group_size(i) < self.get_group_size(j):
i, j = j, i
... |
s872207323 | p02558 | u102655885 | 1599940481 | Python | Python (3.8.2) | py | Runtime Error | 30 | 10404 | 1345 |
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 =... |
s462932513 | p02558 | u102655885 | 1599940229 | Python | Python (3.8.2) | py | Runtime Error | 2364 | 140804 | 1357 | class UnionFind:
def __init__(self, length):
self.parent_indexes = [-1]* length
def union(self, i, j):
if i == j:
return
# iが所属する集団のサイズ>=jが所属する集団のサイズにする
if self.get_group_size(i) < self.get_group_size(j):
i, j = j, i
self.parent_indexes[i]... |
s408621468 | p02558 | u102655885 | 1599939916 | Python | Python (3.8.2) | py | Runtime Error | 802 | 12360 | 1305 | class UnionFind:
def __init__(self, length):
self.parent_indexes = [-1]* length
def union(self, i, j):
# iが所属する集団のサイズ>=jが所属する集団のサイズにする
if self.get_group_size(i) < self.get_group_size(j):
i, j = j, i
self.parent_indexes[i] = - self.get_group_size(i) - self.get... |
s228761989 | p02558 | u102655885 | 1599935470 | Python | Python (3.8.2) | py | Runtime Error | 721 | 42440 | 352 | from collections import defaultdict
links = defaultdict(set)
n, q = list(map(lambda x: int(x), input().split()))
for _ in range(n):
t, u, v = list(map(lambda x: int(x), input().split()))
if t == 0:
links[min(u, v)].add(max(u, v))
links[v].add(u)
continue
print('1') if max(u, v) in l... |
s399830650 | p02558 | u942356554 | 1599906026 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9140 | 432 | n,m,t = map(int,input().split())
shop = []
for i in range(n):
shop.append([0]*t)
cash = []
for i in range(m):
ts, id1 = map(int,input().split())
shop[id1-1][ts-1] += 1
for i in range(len(shop)):
chek = 0
for j in range(t):
if shop[i][j] == 0:
if chek != 0:
chek-=... |
s155688470 | p02558 | u509368316 | 1599845997 | Python | Python (3.8.2) | py | Runtime Error | 421 | 45440 | 1884 | code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include,/opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/dsu.hpp" ... |
s434574315 | p02558 | u767543103 | 1599776264 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9060 | 69418 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
// const ll MOD = 1000000007;
const ll MOD = 998244353;
const ll INF = MOD * MOD;
const long double EPS = 1e-12;
struct mint {
ll x;
mint(ll x = 0): x((x % MOD + MOD) % MOD){}
mint operator-() const {return mint(-x)... |
s272576090 | p02558 | u576335153 | 1599747335 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8984 | 2529 | // package jp.atcoder.library.kotlin.dsu
import java.util.*
/**
* Disjoint set union.
*/
class DSU(private val n: Int) {
private val parentOrSize = IntArray(n)
/**
* Merge nodes.
*/
fun merge(a: Int, b: Int): Int {
if (a !in 0 until n) throw IndexOutOfBoundsException("a=$a")
i... |
s729625363 | p02558 | u029574076 | 1599687883 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8956 | 7116 | #ifndef ATCODER_CONVOLUTION_HPP
#define ATCODER_CONVOLUTION_HPP 1
#include <algorithm>
#include <array>
#include <atcoder/internal_bit>
#include <atcoder/modint>
#include <cassert>
#include <type_traits>
#include <vector>
namespace atcoder {
namespace internal {
template <class mint, internal::is_static_modint_t<mi... |
s244935369 | p02558 | u029574076 | 1599686969 | Python | Python (3.8.2) | py | Runtime Error | 51 | 12500 | 1981 | #!/usr/bin/env python3
import re
import sys
import argparse
from logging import Logger, basicConfig, getLogger
from os import getenv, environ
from pathlib import Path
from typing import List
logger = getLogger(__name__) # type: Logger
atcoder_include = re.compile('#include\s*["<](atcoder/[a-z_]*(|.hpp))[">]\s*')
... |
s771771364 | p02558 | u201928947 | 1599642446 | Python | PyPy3 (7.3.0) | py | Runtime Error | 5565 | 2053352 | 3043 | 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)
... |
s720272159 | p02558 | u193880030 | 1599640763 | Python | Python (3.8.2) | py | Runtime Error | 332 | 53336 | 269 | import networkx as nx
n, q = map(int, input().split())
G = nx.Gragh()
for i in range(q):
t, u, v = map(int, input().split())
if t == 0:
G.add_edge(u, v)
else:
if len(nx.shortest_path(G, source=u, target=v)) == 0:
print(0)
else:
print(1) |
s943654012 | p02558 | u279493135 | 1599625224 | Python | Python (3.8.2) | py | Runtime Error | 30 | 9060 | 204 | import networkx as nx
def MAP(): return map(int, input().split())
n,q=MAP()
g=nx.utils.UnionFind(range(n))
for _ in range(q):
t,u,v=MAP()
if t==0:g.union(u,v)
else:print(1 if g[u]==g[v] else 0 |
s795753925 | p02558 | u875291233 | 1599600166 | Python | PyPy3 (7.3.0) | py | Runtime Error | 91 | 68704 | 530 | # coding: utf-8
# Your code here!
def floor_sum(n,m,a,b):
ans = n*(b//m)
b %= m
while True:
ans += (n-1)*n*(a//m)//2
a %= m
if a*n+b < m:
return ans
y_max = (a*n + b)//m
b -= y_max*m #now we have x_max = -(b//a)
ans += (n + b//a)*y_max
n =... |
s425907026 | p02558 | u571969099 | 1599589635 | Python | PyPy3 (7.3.0) | py | Runtime Error | 311 | 77524 | 1909 | import sys
input = sys.stdin.readline
from typing import List
class DSU:
def __init__(self, n: int) -> None:
self._n = n
self.parent_or_size = [-1] * n
def merge(self, a: int, b: int) -> int:
assert 0 <= a <= self._n
assert 0 <= b <= self._n
x, y = self.leader(a), self.... |
s602031660 | p02558 | u225388820 | 1599576884 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 68536 | 2469 | class UnionFind:
def __init__(self, N: int):
"""
N:要素数
root:各要素の親要素の番号を格納するリスト.
ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
rank:ランク
"""
self.N = N
self.root = [-1] * N
self.rank = [0] * N
def __repr__(self):
return '\n'.join('{... |
s511682019 | p02558 | u227082700 | 1599569296 | Python | Python (3.8.2) | py | Runtime Error | 261 | 11900 | 832 | import sys
input = lambda: sys.stdin.readline().rstrip()
# UnionFind
class UnionFind:
def __init__(self,n):
self.n=n
self.a=[-1]*n
self.siz=n
def root_find(self,x):
if self.a[x]<0:
return x
else:
self.a[x]=self.root_find(self.a[x])
ret... |
s772728116 | p02558 | u700805562 | 1599567671 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9212 | 874 | class UnionFind:
def __init__(self, size):
self.par = [-1] * size
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, y = self.find(x), self.find(... |
s139766382 | p02558 | u284854859 | 1599564553 | Python | PyPy3 (7.3.0) | py | Runtime Error | 132 | 69328 | 988 | #Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
tank = []
while par[x] >= 0:
tank.append(x)
x = par[x]
for elt in tank:
par[elt] = x
return x
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x =... |
s387924309 | p02558 | u965730380 | 1599515396 | Python | PyPy3 (7.3.0) | py | Runtime Error | 99 | 68444 | 1162 | #include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <atcoder/dsu>
using namespace std;
using namespace atcode... |
s562145071 | p02559 | u597455618 | 1600305746 | Python | Python (3.8.2) | py | Runtime Error | 1802 | 145948 | 1004 | import numpy as np
from numba import njit, i8, jitclass
import sys
spec = [
("size", i8),
("tree", i8[:])
]
@jitclass(spec)
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr, np.int64)
for i in range(1, n+1):
self.tree[i + 1 | i + 2] +... |
s759856812 | p02559 | u597455618 | 1600305707 | Python | Python (3.8.2) | py | Runtime Error | 1785 | 146308 | 1003 | import numpy as np
from numba import njit, i8, jitclass
import sys
spec = [
("size", i8),
("tree", i8[:])
]
@jitclass(spec)
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = np.array([0] + arr, np.int64)
for i in range(1, n+1):
self.tree[i + (i & -i)] +=... |
s805796337 | p02559 | u597455618 | 1600302846 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9152 | 908 | import sys
class Bit:
def __init__(self, n, arr):
self.size = n
self.tree = [0] + arr
for i in range(1, n+1):
if i + (i & -i) < n+1:
self.tree[i + (i & -i)] += self.tree[i]
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
... |
s146548795 | p02559 | u597455618 | 1600300015 | Python | Python (3.8.2) | py | Runtime Error | 1190 | 60888 | 803 | import sys
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += ... |
s613531226 | p02559 | u785989355 | 1600199941 | Python | Python (3.8.2) | py | Runtime Error | 28 | 8940 | 840 | # distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
cimport numpy as np
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fenwick_tree[T]:... |
s372939922 | p02559 | u785989355 | 1600199673 | Python | Python (3.8.2) | py | Runtime Error | 253 | 83848 | 1408 |
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
cimport numpy as np
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder" nogil:
cdef cppclass fen... |
s172951863 | p02559 | u785989355 | 1600147083 | Python | Python (3.8.2) | py | Runtime Error | 879 | 63584 | 1216 |
code = """
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
cdef extern from "<atcoder/fenwicktree>" namespace "atcoder":
cdef cppclass fenwick_tree[T]:
fe... |
s843063672 | p02559 | u353919145 | 1600023343 | Python | Python (3.8.2) | py | Runtime Error | 5513 | 65212 | 805 | def p(k: int):
ans = 0
for i in range(20):
if k % (1<<i) == 0:
ans = i
else:
break
return ans
def sum_f(k: int, tree: list):
s = 0
while k >= 1:
s += tree[k]
k -= k&-k
return s
def add(k: int, x: int, tree: list):
while k <= len(tree)... |
s032825749 | p02559 | u767543103 | 1599950108 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9012 | 3118 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFo... |
s094420569 | p02559 | u102655885 | 1599949035 | Python | Python (3.8.2) | py | Runtime Error | 245 | 65032 | 601 | n, q = list(map(lambda x: int(x), input().split()))
list_a = list(map(lambda x: int(x), input().split()))
# element of ith index is the sum of subarray: list_a[:i+1]
current_sum = 0
sum_list_a = []
for ele in list_a:
# print(ele, current_sum)
current_sum += ele
sum_list_a.append(current_sum)
for _ in rang... |
s874156747 | p02559 | u102655885 | 1599948555 | Python | Python (3.8.2) | py | Runtime Error | 246 | 65060 | 593 | n, q = list(map(lambda x: int(x), input().split()))
list_a = list(map(lambda x: int(x), input().split()))
# element of ith index is the sum of subarray: list_a[:i+1]
current_sum = 0
sum_list_a = []
for ele in list_a:
# print(ele, current_sum)
current_sum += ele
sum_list_a.append(current_sum)
for _ in rang... |
s199127969 | p02559 | u350248178 | 1599948326 | Python | Python (3.8.2) | py | Runtime Error | 149 | 65132 | 457 | n,q=map(int,input().split())
a=list(map(int,input().split()))
bit=[0]*(2*n+10)
def bit_update(x,v):
while x<size:
bit[x]+=v
x+=(x&-x)
def bit_sum(n):
s=0
if n==0:return 0
x=n
while x>0:
s+=bit[x]
x-=(x&-x)
return s
for i,j in enumerate(a,1):
bit_update(i,j)
fo... |
s962255041 | p02559 | u350248178 | 1599948260 | Python | Python (3.8.2) | py | Runtime Error | 2349 | 65076 | 468 | n,q=map(int,input().split())
a=list(map(int,input().split()))
size=(1<<18)+1
bit=[0]*size
def bit_update(x,v):
while x<size:
bit[x]+=v
x+=(x&-x)
def bit_sum(n):
s=0
if n==0:return 0
x=n
while x>0:
s+=bit[x]
x-=(x&-x)
return s
for i,j in enumerate(a,1):
bit_upd... |
s633982838 | p02559 | u102655885 | 1599944973 | Python | Python (3.8.2) | py | Runtime Error | 247 | 65196 | 570 | n, q = list(map(lambda x: int(x), input().split()))
list_a = list(map(lambda x: int(x), input().split()))
# element of ith index is the sum of subarray: list_a[:i+1]
current_sum = 0
sum_list_a = []
for ele in list_a:
# print(ele, current_sum)
current_sum += ele
sum_list_a.append(current_sum)
for _ in rang... |
s832963549 | p02559 | u708618797 | 1599727343 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9048 | 916 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s211710817 | p02559 | u708618797 | 1599727271 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9040 | 915 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s655450438 | p02559 | u708618797 | 1599727124 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9104 | 909 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s805253906 | p02559 | u708618797 | 1599726956 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9100 | 897 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s172094143 | p02559 | u708618797 | 1599726918 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9076 | 896 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s372541001 | p02559 | u708618797 | 1599726871 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9076 | 917 | code = r"""
# distutils: language=c++
# distutils: include_dirs=/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.vector cimport vector
cdef extern from "/opt/atcoder-stl/atcoder/fenwicktree.hpp" namespace "... |
s618299835 | p02560 | u327466606 | 1600648373 | Python | PyPy3 (7.3.0) | py | Runtime Error | 117 | 98896 | 609 | def floor_linear_sum(n,m,a,b):
"""
returns sum((a*i+b)//m for i in range(n))
"""
res = 0
while True:
if a >= m:
res += (n-1)*n*(a//m)//2
a %= m
if b >= m:
res += n * (b//m)
b %= m
y_max = (a*n+b)//m
if y_max == 0:
... |
s974877642 | p02560 | u879309973 | 1600406241 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9180 | 381 | def solve(n, m, a, b):
if n == 0:
return 0
res = 0
if a > m:
res += (n-1) * n // 2 * (a // m)
a %= m
if b > m:
res += n * (b // m)
b %= m
p = (a*n + b) // m
q = p*m - b
return res + solve(p, a, m, a*n-q)
t = int(input())
for i in range(t):
n, m, a... |
s855528178 | p02560 | u168578024 | 1599534297 | Python | PyPy3 (7.3.0) | py | Runtime Error | 123 | 74540 | 8028 | #pragma region kyopro_template
#define Nyaan_template
#include <immintrin.h>
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, v... |
s227268465 | p02561 | u481187938 | 1600625826 | Python | Python (3.8.2) | py | Runtime Error | 255 | 16872 | 5435 | # thanks: https://atcoder.jp/contests/practice2/submissions/16784996
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools
import math, fr... |
s294340742 | p02561 | u481187938 | 1600624988 | Python | Python (3.8.2) | py | Runtime Error | 259 | 17220 | 5377 | # thanks: https://atcoder.jp/contests/practice2/submissions/16784996
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools
import math, fr... |
s843595965 | p02561 | u481187938 | 1600613109 | Python | Python (3.8.2) | py | Runtime Error | 255 | 16304 | 6312 | # thanks: https://atcoder.jp/contests/practice2/submissions/16784996
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools
import math, fr... |
s561885548 | p02561 | u994521204 | 1600612883 | Python | Python (3.8.2) | py | Runtime Error | 5401 | 112612 | 1367 | import networkx as nx
n, m = map(int, input().split())
def calc(i, j): # 0<=i<n, 0<=j<m
return i * m + j
def inv(num):
return num // m, num % m
S = [list(input()) for _ in range(n)]
start = n * m
goal = start + 1
G = nx.Graph()
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
for num in range(n * m):
i, j = in... |
s296813995 | p02561 | u481187938 | 1600612625 | Python | Python (3.8.2) | py | Runtime Error | 4783 | 16536 | 5568 | #!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify
import itertools
import math, fractions
import sys, copy
def L(): return sys.stdin.readline().split()... |
s857963277 | p02561 | u994521204 | 1600612292 | Python | Python (3.8.2) | py | Runtime Error | 5376 | 112604 | 1277 | import networkx as nx
n, m = map(int, input().split())
def calc(i, j): # 0<=i<n, 0<=j<m
return i * m + j
def inv(num):
return num // m, num % m
S = [list(input()) for _ in range(n)]
start = n * m
goal = start + 1
G = nx.Graph()
di = [1, 0, -1, 0]
dj = [0, 1, 0, -1]
for num in range(n * m):
i, j = in... |
s859514534 | p02561 | u994521204 | 1600611736 | Python | Python (3.8.2) | py | Runtime Error | 4349 | 112624 | 1245 | import networkx as nx
n, m = map(int, input().split())
def calc(i, j): # 0<=i<n, 0<=j<m
return i * m + j
def inv(num):
return num // m, num % m
S = [list(input()) for _ in range(n)]
start = n * m
goal = start + 1
G = nx.Graph()
for num in range(n * m):
i, j = inv(num)
if S[i][j] == "#":
... |
s889805188 | p02561 | u994521204 | 1600611651 | Python | Python (3.8.2) | py | Runtime Error | 4448 | 112332 | 1310 | import networkx as nx
n, m = map(int, input().split())
def calc(i, j): # 0<=i<n, 0<=j<m
return i * m + j
def inv(num):
return num // m, num % m
S = [list(input()) for _ in range(n)]
start = n * m
goal = start + 1
G = nx.Graph()
for num in range(n * m):
i, j = num // m, num % m
if S[i][j] == "#":... |
s265943069 | p02561 | u467736898 | 1600560180 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9252 | 21122 | # TODO: メモリリーク確認
# TODO: min_cut, change_edge が正しく動くか確認
code_mf_graph = r"""
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "structmember.h"
#include <memory>
// 元のライブラリの private を剥がした
// >>> AtCoder >>>
#ifndef ATCODER_MAXFLOW_HPP
#define ATCODER_MAXFLOW_HPP 1
#include <algorithm>
#ifndef ATCODER_INTERNAL... |
s691718940 | p02561 | u562016607 | 1600532644 | Python | PyPy3 (7.3.0) | py | Runtime Error | 161 | 101812 | 4820 | from collections import deque
class mf_graph():
n=1
g=[[] for i in range(n)]
pos=[]
def __init__(self,N):
self.n=N
self.g=[[] for i in range(N)]
def add_edge(self,f,t,cap):
assert 0<=f<self.n, "0<=from<n,(from,n)=({0},{1})".format(f,self.n)
assert 0<=t<self.n, "0<=to<... |
s405702905 | p02561 | u562016607 | 1600531697 | Python | Python (3.8.2) | py | Runtime Error | 135 | 22112 | 4962 | from collections import deque
class mf_graph():
n=1
g=[[] for i in range(n)]
pos=[]
def __init__(self,N):
self.n=N
self.g=[[] for i in range(N)]
def add_edge(self,f,t,cap):
assert 0<=f<self.n, "0<=from<n,(from,n)=({0},{1})".format(f,self.n)
assert 0<=t<self.n, "0<=to<... |
s516922250 | p02561 | u102461423 | 1600506087 | Python | Python (3.8.2) | py | Runtime Error | 647 | 82832 | 1139 | import sys
import itertools
import numpy as np
import networkx as nx
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
S = np.frombuffer(read(), 'S1').reshape(N, -1)[:, :M].astype('U1')
A = []
B = []
E = []
for i, j in iterto... |
s306515239 | p02561 | u102461423 | 1600506068 | Python | Python (3.8.2) | py | Runtime Error | 557 | 69820 | 1144 | import sys
import itertools
import numpy as np
import networkx as nx
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
S = np.frombuffer(read(), 'S1').reshape(N, -1)[:, :M].astype('U1')
A = []
B = []
E = []
for i, j in iterto... |
s885044311 | p02561 | u102461423 | 1600505637 | Python | Python (3.8.2) | py | Runtime Error | 549 | 69664 | 1137 | import sys
import itertools
import numpy as np
import networkx as nx
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
S = np.frombuffer(read(), 'S1').reshape(N, -1)[:, :M].astype('U1')
A = []
B = []
E = []
for i, j in iterto... |
s997601362 | p02561 | u535803878 | 1600375843 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 68568 | 1695 | import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
n,m = list(map(int, input().split()))
s = [input() for _ in range(n)]
# scipyの例
import scipy.sparse
data = []
rs = []
cs = []
def add(i,j,v=1,directed=False):
rs.append(i)
... |
s171662862 | p02561 | u623231048 | 1600342294 | Python | PyPy3 (7.3.0) | py | Runtime Error | 254 | 81072 | 4189 | from collections import deque
class MaxFlow:
def __init__(self, n):
self.n = n
self.graph = [[] for _ in range(n)]
self.pos = []
def add_edge(self, fr, to, cap):
m = len(self.pos)
self.pos.append((fr, len(self.graph[fr])))
self.graph[fr].append([to, len(self.gra... |
s848855880 | p02561 | u623231048 | 1600342163 | Python | PyPy3 (7.3.0) | py | Runtime Error | 268 | 81180 | 4189 | from collections import deque
class MaxFlow:
def __init__(self, n):
self.n = n
self.graph = [[] for _ in range(n)]
self.pos = []
def add_edge(self, fr, to, cap):
m = len(self.pos)
self.pos.append((fr, len(self.graph[fr])))
self.graph[fr].append([to, len(self.gra... |
s416893232 | p02561 | u623231048 | 1600341948 | Python | PyPy3 (7.3.0) | py | Runtime Error | 263 | 81260 | 4183 | from collections import deque
class MaxFlow:
def __init__(self, n):
self.n = n
self.graph = [[] for _ in range(n)]
self.pos = []
def add_edge(self, fr, to, cap):
m = len(self.pos)
self.pos.append((fr, len(self.graph[fr])))
self.graph[fr].append([to, len(self.gra... |
s495900272 | p02561 | u623231048 | 1600341887 | Python | PyPy3 (7.3.0) | py | Runtime Error | 295 | 81768 | 4205 | from collections import deque
class MaxFlow:
def __init__(self, n):
self.n = n
self.graph = [[] for _ in range(n)]
self.pos = []
def add_edge(self, fr, to, cap):
m = len(self.pos)
self.pos.append((fr, len(self.graph[fr])))
self.graph[fr].append([to, len(self.gra... |
s150087185 | p02561 | u216928054 | 1600302090 | Python | PyPy3 (7.3.0) | py | Runtime Error | 436 | 93360 | 6105 | #!/usr/bin/env python3
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
INF = 10 ** 10
def init():
global edges
edges = defaultdict(dict)
def add_edge(frm, to, capacity):
edges[frm... |
s577995056 | p02561 | u216928054 | 1600301625 | Python | PyPy3 (7.3.0) | py | Runtime Error | 450 | 93144 | 5858 | #!/usr/bin/env python3
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
INF = 10 ** 10
def init():
global edges
edges = defaultdict(dict)
def add_edge(frm, to, capacity):
edges[frm... |
s623647459 | p02561 | u216928054 | 1600300792 | Python | PyPy3 (7.3.0) | py | Runtime Error | 424 | 92440 | 5318 | #!/usr/bin/env python3
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
INF = 10 ** 10
edges = defaultdict(dict)
def add_edge(frm, to, capacity):
edges[frm][to] = capacity
edges[to][frm]... |
s393329496 | p02561 | u216928054 | 1600300747 | Python | PyPy3 (7.3.0) | py | Runtime Error | 420 | 92092 | 5314 | #!/usr/bin/env python3
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
INF = 10 ** 10
edges = defaultdict(dict)
def add_edge(frm, to, capacity):
edges[frm][to] = capacity
edges[to][frm]... |
s851980182 | p02561 | u216928054 | 1600299703 | Python | PyPy3 (7.3.0) | py | Runtime Error | 449 | 93288 | 5284 | #!/usr/bin/env python3
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
INF = 10 ** 10
edges = defaultdict(dict)
def add_edge(frm, to, capacity):
edges[frm][to] = capacity
edges[to][frm]... |
s413555602 | p02561 | u509368316 | 1600107766 | Python | Python (3.8.2) | py | Runtime Error | 124 | 20000 | 5411 | code = r"""
# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include,/opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False
from libcpp cimport bool
from libcpp.string cimport string
from libcpp.vector cimport vector
cdef extern from ... |
s570695999 | p02561 | u864197622 | 1600038199 | Python | PyPy3 (7.3.0) | py | Runtime Error | 124 | 78680 | 3351 | class maxflow():
def __init__(self, n):
self.pos = []
self.g = [[] for _ in range(n)]
self.n = n
def add_edge(self, v, w, cap):
e1 = [w, 0, cap]
e2 = [v, e1, 0]
e1[1] = e2
self.g[v].append(e1)
self.g[w].append(e2)
def flow(self, s, t,... |
s065452178 | p02561 | u960080897 | 1599953456 | Python | Python (3.8.2) | py | Runtime Error | 126 | 25128 | 44602 | # AC Library Python版
# Author Koki_tkg
'''
internal_type_traits以外は翻訳しました。
practiceは一応全部ACしていますが,
practiceで使っていない関数などの動作は未確認なので保証はしません。
また,C++版をほぼそのまま書き換えているので速度は出ません。 (2020/09/13 by Koki_tkg)
'''
# --------------------<< Library Start >>-------------------- #
# convolution.py
class convolution:
def __init__(self,... |
s309339380 | p02561 | u456353530 | 1599939141 | Python | PyPy3 (7.3.0) | py | Runtime Error | 331 | 85428 | 3631 | #test
NUMERIC_LIMITS = 10 ** 18
import queue
class maxFlow:
class edge:
def __init__(s, frm, to, cap, flow):
s.frm, s.to = frm, to
s.cap, s.flow = cap, flow
def __init__(s, n):
s._n = n
s.g = [[] for _ in range(n)]
s.pos = []
def add_edge(s, frm, to, cap):
m = len(s.pos)
s.po... |
s069627020 | p02561 | u844789719 | 1599783778 | Python | Python (3.8.2) | py | Runtime Error | 303 | 40884 | 1198 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import maximum_flow, maximum_bipartite_matching
import copy
N, M = [int(_) for _ in input().split()]
A = [['#'] * (M + 2)] + [list('#' + input() + '#')
for _ in range(N)] + [['#'] * (M + 2)]
A2 = copy.deepcopy(A)
S = ''.join(''.join(... |
s567296757 | p02561 | u844789719 | 1599783699 | Python | Python (3.8.2) | py | Runtime Error | 253 | 39396 | 1230 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import maximum_flow, maximum_bipartite_matching
import copy
N, M = [int(_) for _ in input().split()]
A = [['#'] * (M + 2)] + [list('#' + input() + '#')
for _ in range(N)] + [['#'] * (M + 2)]
A2 = copy.deepcopy(A)
S = ''.join(''.join(... |
s806549455 | p02561 | u844789719 | 1599783582 | Python | Python (3.8.2) | py | Runtime Error | 260 | 38980 | 1204 | from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import maximum_flow, maximum_bipartite_matching
import copy
N, M = [int(_) for _ in input().split()]
A = [['#'] * (M + 2)] + [list('#' + input() + '#')
for _ in range(N)] + [['#'] * (M + 2)]
A2 = copy.deepcopy(A)
S = ''.join(''.join(... |
s574561171 | p02561 | u994988729 | 1599776976 | Python | Python (3.8.2) | py | Runtime Error | 100 | 11684 | 2190 | class BipartiteMatching:
def __init__(self, N, M):
self.N = N
self.M = M
self.pairA = [-1] * N
self.pairB = [-1] * M
self.edge = [[] for _ in range(N)]
self.was = [0] * N
self.iter = 0
def add(self, s, t):
self.edge[s].append(t)
def _DFS(self... |
s499308947 | p02561 | u034128150 | 1599683091 | Python | PyPy3 (7.3.0) | py | Runtime Error | 132 | 78248 | 3772 | # https://atcoder.jp/contests/practice2/submissions/16598132
# 上記のリンクの提出をいじらせてもらってます。
from collections import deque
class mf_graph:
__slots__ = ["N", "graph"]
def __init__(self, N):
self.N = N
self.graph = [[] for _ in range(N)]
def add_edge(self, v, w, cap):
edge = [w, cap, No... |
s751447681 | p02561 | u201928947 | 1599682815 | Python | PyPy3 (7.3.0) | py | Runtime Error | 237 | 89040 | 2976 | # Dinic's algorithm
#https://tjkendev.github.io/procon-library/python/max_flow/dinic.htmlより
from collections import deque
class Dinic:
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap):
forward = [to, cap, None]
forward[2] = backwa... |
s131343889 | p02561 | u201928947 | 1599682760 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 68544 | 2979 | # Dinic's algorithm
#https://tjkendev.github.io/procon-library/python/max_flow/dinic.htmlより
from collections import deque
class Dinic:
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap):
forward = [to, cap, None]
forward[2] = backwa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.