input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
X, Y, A, B, C = list(map(int, input().split()))
*P, = list(map(int, input().split()))
*Q, = list(map(int, input().split()))
*R, = list(map(int, input().split()))
P = sorted(P, reverse=True)
Q = sorted(Q, reverse=True)
R = sorted(R, reverse=True)
P = P[:X]
Q = Q[:Y]
PQ = sorted(P + Q)
ans = 0
cnt = 0
if X + ... | X, Y, A, B, C = list(map(int, input().split()))
*P, = list(map(int, input().split()))
*Q, = list(map(int, input().split()))
*R, = list(map(int, input().split()))
P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
print((sum(sorted(P + Q + R, reverse=True)[:X + Y])))
| p02727 |
m, d = list(map(int,input().split()))
n, e = list(map(int,input().split()))
print((int(n >= 2 and e == 1))) | m, d = list(map(int,input().split()))
n, e = list(map(int,input().split()))
print((int(e == 1))) | p02841 |
m1,d1=list(map(int,input().split()))
m2,d2=list(map(int,input().split()))
print(((m1<m2 and d1>d2)+0)) | m,d=list(map(int,input().split()))
mm,dd=list(map(int,input().split()))
print(('01'[m<mm])) | p02841 |
a,b=open(0);print((+(a[:2]!=b[:2]))) | print((+(input()[:2]!=input()[:2]))) | p02841 |
print((1//int([*open(0)][1][2:]))) | print((+(' 1\n'in[*open(0)][1]))) | p02841 |
M1, D1 = list(map(int, input().split()))
M2, D2 = list(map(int, input().split()))
if M1 == M2:
print((0))
else:
print((1))
| li = [list(input().split()) for _ in range(2)]
print((0 if li[0][0] == li[1][0] else 1))
| p02841 |
N=int(eval(input()))
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
for j in range(0,N):
for k in range(0,N):
if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
if i!=j and j!=k and k!=i:
... | N=int(eval(input()))
li = list(map(int, input().split()))
c=0
ali=[]
for i in range(0,N):
for j in range(0,N):
for k in range(0,N):
if li[i]+li[j]>li[k] and li[j]+li[k]>li[i] and li[k]+li[i]>li[j]:
if li[i]!=li[j] and li[j]!=li[k] and li[k]!=li[i]:
if i!=j and j!=k and k!=i and i<... | p02583 |
#! env/bin/local python3
# -*- coding: utf-8 -*-
from itertools import combinations
def is_tri(_a, _b, _c):
if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
return True
else:
return False
n = int(eval(input()))
sticks = list(map(int, input().split()))
h = combinatio... | #! env/bin/local python3
# -*- coding: utf-8 -*-
from itertools import combinations
def is_tri(_a, _b, _c):
if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
return True
else:
return False
n = int(eval(input()))
sticks = list(map(int, input().split()))
h = combinatio... | p02583 |
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
n, *l = list(map(int, read().split()))
if n < 3:
print((0))
sys.exit()
com = tuple(combinations(l, 3))
r = 0
for c in com:
c1 = c[0]
c2 = c[1]
... | import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from itertools import combinations
def main():
n, *a = list(map(int, read().split()))
coma = combinations(a, 3)
r = 0
for c in coma:
if sum(c) > max(c)*2:
if len(set(c)) > 2:
r += 1
print... | p02583 |
N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L)
res = []
cnt = 0
for i in range(len(L)):
Li = L[i]
for j in range(len(L)):
Lj = L[j]
for k in range(len(L)):
Lk = L[k]
if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
if Li != Lj and Lj!= Lk and Lk... | import itertools
N = int(eval(input()))
L = list(map(int, input().split()))
L = sorted(L)
ref = list(itertools.combinations(L, 3))
cnt = 0
for i in ref:
Li = i[0]
Lj = i[1]
Lk = i[2]
if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
if Li != Lj and Lj!= Lk and Lk != Li:
cnt += 1
pri... | p02583 |
N = int(eval(input()))
L = list(map(int, input().split()))
cnt = 0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
if L[i]!=L[j] and L[j]!=L[k] and L[k]!=L[i]:
if L[i] < L[j] + L[k] and L[j] < L[k] + L[i] and L[k] < L[i] + L[j]:
... | n=int(eval(input()))
l = list(map(int, input().split()))
cnt = 0
# 3つの相異なる数字(i, j, k)の組み合わせを調べること
for i in range(n):
for j in range(i+1, n):
for k in range(j+1, n):
a = l[i]
b = l[j]
c = l[k]
if a == b or b == c or c == a:
contin... | p02583 |
N = int(eval(input()))
L = list(map(int, input().split()))
cnt = 0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
if sorted(L)[::-1][i] < sorted(L)[::-1][j] + sorted(L)[::-1][k]:
if sorted(L)[::-1][i] != sorted(L)[::-1][j] != sorted(L)[::-1][k]:
... | N = int(eval(input()))
L = sorted(list(map(int, input().split())))[::-1]
cnt = 0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
if L[i] < L[j] + L[k]:
if L[i] != L[j] != L[k]:
cnt += 1
print(cnt) | p02583 |
n,*l=list(map(int,open(0).read().split()))
print((sum(i!=j!=k!=i and j+k>i and k+i>j and i+j>k for i in l for j in l for k in l)//6)) | n,*l=list(map(int,open(0).read().split()))
l.sort()
print((sum(i<j<k and i+j>k for i in l for j in l for k in l))) | p02583 |
N = int(eval(input()))
L = [int(x) for x in input().split()]
cnt = 0
for i in range(len(L) - 2):
for j in range(i+1, len(L)-1):
for k in range(j+1, len(L)):
a = L[i]
b = L[j]
c = L[k]
p = a + b > c
q = b + c > a
r = c + a >... | N = int(eval(input()))
L = [int(x) for x in input().split()]
L.sort()
cnt = 0
for i in range(len(L) - 2):
for j in range(i+1, len(L)-1):
for k in range(j+1, len(L)):
a = L[i]
b = L[j]
c = L[k]
p = a + b > c
s = a != b
t = ... | p02583 |
import sys
def main():
import itertools
input = sys.stdin.readline
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in itertools.combinations(l, 3):
if len(set(i)) == 3 and abs(i[0] - i[1]) < i[2] < i[0] + i[1]:
ans += 1
print(ans)
... | #!/usr/bin/env python3
import sys
def main():
import itertools
input = sys.stdin.readline
_ = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in itertools.combinations(l, 3):
if len(set(i)) == 3 and abs(i[0] - i[1]) < i[2] < i[0] + i[1]:
ans +... | p02583 |
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
for j in range(i+1, n-1):
for k in range(j+1, n):
if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
if l[i]+l[j] > l[k] and l[i]+l[k] > l[j] and l[j]+l[k] > l[i]: ans += 1
print(ans) | from itertools import combinations
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i,j,k in combinations(l,3):
if i == j or i == k or j == k: continue
if i >= j+k or j >= i+k or k >= i+j: continue
ans += 1
print(ans) | p02583 |
n = int(eval(input()))
l = list(map(int,input().split()))
nums = set([])
for i in range(n):
for j in range(i,n):
for k in range(j,n):
if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
continue
else:
ver = [l[i],l[j],l[k]]
num... | n = int(eval(input()))
l = list(map(int,input().split()))
ans = 0
for i in range(n):
for j in range(i,n):
for k in range(j,n):
if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
continue
else:
ver = [l[i],l[j],l[k]]
ver.sort()... | p02583 |
#!/usr/bin/env python
import sys
import argparse
import logging
#import math
logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
def f(n: int, l_list: list, i: int = None, j: int = None, k: int = None) -> int:
'''
... | #!/usr/bin/env python
import sys
import argparse
import logging
#import math
logging.basicConfig(filename='logger.log', level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
def f(n: int, l_list: list, i: int = None, j: int = None, k: int = None) -> int:
'''
... | p02583 |
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
a,b,c=L[i],L[j],L[k]
if a!=b and b!=c and a+b>c:
ans+=1
print(ans)
| N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range(N-2):
a=L[i]
for j in range(i+1,N-1):
b=L[j]
if a==b:
continue
for k in range(j+1,N):
c=L[k]
if b==c:
continue
ans+=a+b>c
... | p02583 |
n = int(eval(input()))
l = sorted(map(int, input().split()))[::-1]
ans = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if l[k] < l[j] < l[i] and l[k] + l[j] > l[i]:
ans += 1
print(ans)
| n = int(eval(input()))
l = sorted(map(int, input().split()))[::-1]
ans = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if l[k] < l[j] < l[i] < l[k] + l[j]:
ans += 1
print(ans)
| p02583 |
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
n = int(readline())
l = list(map(int, readline().split()))
ans = 0
for i in range(n):
a = l[i]
for j in range(i + 1, n):
b = l[j]
... | n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if l[i] != l[j] != l[k]:
if l[i] + l[j] > l[k]:
ans += 1
print(ans)
| p02583 |
import itertools as it
N = int(eval(input())) - 1
s = list(map(int, input().split()))
count = 0
c = it.combinations(s, 3)
for i in c:
listed = list(i)
if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
continue
maximum = max(listed)
listed.remove(max... | import itertools as it
N = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
count = 0
c = it.combinations(s, 3)
for i in c:
listed = list(i)
if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
continue
if (listed[0] + listed[1]) > listed[... | p02583 |
import itertools as it
N = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
count = 0
c = it.combinations(s, 3)
for i in c:
listed = list(i)
if listed[0] == listed[1] or listed[1] == listed[2] or listed[2] == listed[0]:
continue
if (listed[0] + listed[1]) > listed[... | import itertools as it
N = int(eval(input()))
s = list(map(int, input().split()))
s.sort()
count = 0
c = it.combinations(s, 3)
for i in c:
if i[0] == i[1] or i[1] == i[2] or i[2] == i[0]:
continue
elif (i[0] + i[1]) > i[2]:
count += 1
print(count) | p02583 |
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
if(N >= 3):
t = []
for i in range(N):
for j in range(i+1, N):
for k in range(j+1, N):
if((L[i] != L[j]) & (L[i] != L[k]) & (L[j] != L[k]) & (abs(L[j]-L[k]) < L[i]) & (L[i] < L[j]+L[k])): t.append((L[i], L[j], L[k]))
a... | N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
for i in range(N):
for j in range(i+1, N):
for k in range(j+1, N):
if(L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and abs(L[j]-L[k]) < L[i] and L[i] < L[j]+L[k]):
ans +=1
print(ans) | p02583 |
N=int(eval(input()))
L=list(map(int,input().split(' ')))
l=0
T=[]
for i in range(N):
for j in range(N):
for k in range(N):
if i!=k and i!=j and j!=k:
u=[i,j,k]
u.sort()
if u not in T:
T.append(u)
... | import itertools
N=int(eval(input()))
L=list(map(int,input().split(' ')))
l=0
T=[]
for u in list(itertools.combinations(L, 3)):
i,j,k=u
if 2*max(i,j,k)<i+j+k and i!=k and i!=j and j!=k:
l=l+1
print(l) | p02583 |
import sys
input = sys.stdin.readline
import itertools as it
def li():
return [int(x) for x in input().split()]
N = int(eval(input()))
L = li()
# 組み合わせ列挙
c = it.combinations(L, 3)
c_list = list(c)
cnt = 0
for l in c_list:
unique_l = len(set(l))
if unique_l != 3:
continue
s... | import sys
input = sys.stdin.readline
import itertools as it
def li():
return [int(x) for x in input().split()]
N = int(eval(input()))
L = li()
# 組み合わせ列挙
com = it.combinations(L, 3)
com_list = list(com)
cnt = 0
for l in com_list:
unique_l = len(set(l))
if unique_l != 3:
continu... | p02583 |
import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N - 2):
for j in range(i + 1, N - 1):
if L[i] == L[j]:
conti... | import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
# for i in range(N - 2):
# for j in range(i + 1, N - 1):
# if L[i] == L[j]:
# ... | p02583 |
import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
# for i in range(N - 2):
# for j in range(i + 1, N - 1):
# if L[i] == L[j]:
# ... | import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
... | p02583 |
import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
... | import sys
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
t = L[i... | p02583 |
import sys
import bisect
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L[j]:
break
... | import sys
from bisect import bisect_left, bisect_right
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L... | p02583 |
import sys
from bisect import bisect_left, bisect_right
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
for i in range(j):
if L[i] == L... | import sys
from bisect import bisect_left, bisect_right
def input():
return sys.stdin.readline().rstrip()
def main():
N = int(eval(input()))
L = list(map(int, input().split()))
L.sort()
count = 0
for j in range(1, N - 1):
rem = L[j + 1:]
for i in range(j):
... | p02583 |
has_duplicates= lambda seq:len(seq) == len(set(seq))
def main():
n=int(eval(input()))
l=list(map(int,input().split()))
tel=[-1,-1,-1]
temp=0
bn=0
tc=0
pc=0
i=0
while len(bin(i))-3<n:
if str(bin(i)).count('1')==3:
bn=bin(i)
tc=0
... | def main():
n=int(eval(input()))
l=list(map(int,input().split()))
ans=0
for i in range(n):
for k in range(i+1,n):
for j in range(k+1,n):
temp=[l[i],l[k],l[j]]
if len(set(temp))==len(temp):
temp.sort()
i... | p02583 |
import itertools
N=int(eval(input()))
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
pair=sorted(any_pair)
#print(type(pair))
if pair[0]+pair[1]>pair[2] and pair[1]+pair[2]>pair[0] and pair[0]+pair[2]>pair[1] and pair[0]!=pair[1] and pair[1]!=pair[2]:
a... | import itertools
N=int(eval(input()))
A=list(map(int, input().split()))
ans=0
for any_pair in itertools.combinations(A, 3):
pair=sorted(any_pair)#新しいリストを作成
#print(type(pair))
if pair[0]+pair[1]>pair[2] and pair[0]!=pair[1] and pair[1]!=pair[2]:
ans+=1
#print(pair)
print(ans) | p02583 |
n = int(eval(input()))
L = [*list(map(int, input().split()))]
M = {}
for l in L:
if l in M:
M[l] +=1
else:
M[l] = 1
M = list(M.items())
M.sort()
# print(L)
# print(M)
m=len(M)
c=0
for i in range(m):
for j in range(i+1, m):
for k in range(j+1, m):
if M[i][... | n = int(eval(input()))
L = [*list(map(int, input().split()))]
M = {}
for l in L:
if l in M: M[l] += 1
else: M[l] = 1
M = list(M.items())
M.sort()
m = len(M)
c = 0
for i in range(m):
for j in range(i+1, m):
for k in range(j+1, m):
if M[i][0]+M[j][0] > M[k][0]:
... | p02583 |
from bisect import bisect_left, bisect_right
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
for j in range(i + 1, n):
if l[i] == l[j]:
continue
for k in range(j + 1, n):
if l[i] == l[k] or l[j] == l[k]:
... | from bisect import bisect_left, bisect_right
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for j in range(n):
for k in range(j + 1, n):
if l[j] == l[k]:
continue
ans += max(bisect_left(l, l[j]) - bisect_right(l, l[k] - l[j]), 0)
print(ans)
| p02583 |
n = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(2**n):
tmp = []
for j in range(n):
if ((i >> j) & 1):
tmp .append(a[j])
tmp.sort()
if len(tmp) == 3 and abs(tmp[0]-tmp[1]) < tmp[2] and tmp[2] < tmp[0]+tmp[1] and tmp[0] != tmp[1] != tmp[2]:... | n = int(eval(input()))
a = list(map(int,input().split()))
ans = 0
for i in range(n):
for j in range(1,n):
for k in range(2,n):
tmp = []
if i != j != k and i < j < k:
tmp.append(a[i])
tmp.append(a[j])
tmp.append(a[k])
... | p02583 |
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.r... | import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.r... | p02583 |
n=int(eval(input()))
l=list(map(int,input().split()))
ans=0
for i in range(0,n):
for j in range(i+1,n):
for k in range(j+1,n):
if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
ans+=1
print... | n=int(eval(input()))
L=list(map(int,input().split()))
a=0
for i in range(n-2):
for j in range(i+1,n-1):
if L[i]!=L[j]:
for k in range(j+1,n):
if L[i]!=L[k] and L[j]!=L[k] and L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[j]+L[i]:
... | p02583 |
from itertools import combinations
N = int(eval(input()))
L_list = sorted(list(map(int, input().split())))
ans = 0
for x, y, z in combinations(L_list, 3):
#print(x, y, z)
if x == y or y == z or z == x:
continue
if x + y > z and y + z > x and z + x > y:
ans += 1
print(ans) | from itertools import combinations
N = int(eval(input()))
L_list = list(map(int, input().split()))
ans = 0
for x, y, z in combinations(L_list, 3):
#print(x, y, z)
if x == y or y == z or z == x:
continue
if x + y > z and y + z > x and z + x > y:
ans += 1
print(ans) | p02583 |
# AtCoder Beginner Contest 175
# B - Making Triangle
import bisect
N=int(eval(input()))
L=list(map(int,input().split()))
ans=0
for i in range (N):
for j in range (i+1,N):
for k in range (j+1,N):
# print(i,j,k)
a=min(L[i],L[j],L[k])
c=max(L[i],L[j],L[k])... | # AtCoder Beginner Contest 175
# B - Making Triangle
N=int(eval(input()))
L=list(map(int,input().split()))
L.sort()
ans=0
for i in range (N):
for j in range (i+1,N):
for k in range (j+1,N):
if L[i]+L[j]>L[k] and L[i]<L[j]<L[k]:
ans+=1
print(ans) | p02583 |
# coding: utf-8
from pdb import set_trace
from collections import Counter
N = int(eval(input()))
L = sorted(list(map(int, input().split(" "))), reverse=True)
C = dict(Counter(L))
L = sorted(list(set(L)), reverse=True)
if N<3 or len(L)<3:
print((0))
exit()
li = []
for xa, a in enumerate(L[:-2]):
... | # coding: utf-8
from pdb import set_trace
#from collections import Counter
import itertools
N = int(eval(input()))
L = list(map(int, input().split(" ")))
# print(L)
# C = dict(Counter(L))
# L = sorted(list(set(L)), reverse=True)
# if N<3 or len(L)<3:
# print(0)
# exit()
# li = []
# for xa, a ... | p02583 |
n = int(eval(input()))
l = list(map(int, input().split()))
ans = 0
for i in range(n-2):
for j in range(i + 1, n-1):
for k in range(j + 1, n):
if len({l[i], l[j], l[k]}) != 3:
continue
if l[i] + l[j] > l[k] and l[i] + l[k] > l[j] and l[j] + l[k] > l[i]:
... | from itertools import combinations
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
ans = 0
for li, lj, lk in combinations(l, 3):
if li < lj < lk < li + lj:
ans += 1
print(ans)
| p02583 |
def main():
n = int(eval(input()))
l = sorted(list(map(int, input().split())), reverse=True)
ll = len(l)
ans = 0
seen = []
for i in range(ll):
for j in range(i+1, ll):
for k in range(j+1, ll):
if len(set([l[i], l[j], l[k]])) != 3:
... | def main():
n = int(eval(input()))
l = list(map(int, input().split()))
ll = len(l)
ans = 0
for i in range(ll):
for j in range(i+1, ll):
for k in range(j+1, ll):
if len(set([l[i], l[j], l[k]])) != 3:
continue
item = [... | p02583 |
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
for i in range(1,2**N):
bin_line = str(bin(i))
bin_line = bin_line.replace('0b', '')
line = []
if bin_line.count('1') == 3:
for j in range(len(bin_line)):
if bin_line[j] == '1':
line.append(L[N-len(bin_line)+j])
... | N = int(eval(input()))
L = list(map(int, input().split()))
ans = 0
for i in range(0,N-2):
for j in range(i+1,N-1):
for k in range(j+1,N):
if L[i] != L[j] and L[i] != L[k] and L[j] != L[k] and L[i]+L[j] > L[k] and L[i]+L[k] > L[j] and L[j]+L[k] > L[i]:
ans += 1
print(ans)
| p02583 |
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, ... | # Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, ... | p02583 |
from itertools import combinations
[N],*li = [list(map(int,i.split())) for i in open(0)]
li = li[0]
count = 0
for k in combinations(li,3):
k = sorted(list(k))
if k[2]<k[0]+k[1] and k[0]!=k[1] and k[1]!= k[2]:
count += 1
print(count) | N = int(eval(input()))
li = list(map(int,input().split()))
from itertools import combinations
ans = 0
for k in combinations(li,3):
k = list(k)
k.sort()
if k[0]+k[1]>k[2] and k[0]!=k[1] and k[1]!=k[2]:
ans += 1
print(ans) | p02583 |
N = int(eval(input()))
L_list = list(map(int, input().split()))
result = 0
ind = list(range(len(L_list)))
for i_1 in ind:
ind_2 = list(range(i_1 + 1, len(L_list)))
for i_2 in ind_2:
ind_3 = list(range(i_2 + 1, len(L_list)))
for i_3 in ind_3:
if (L_list[i_1] + L_list[i_2] > L_list[i_3]) and ... | n = int(eval(input()))
a = list(map(int, input().split()))
a = sorted(a)
res = 0
for i in range(n):
for j in range(i + 1, n):
for k in range(j + 1, n):
if len(set([a[i], a[j], a[k]])) < 3:
continue
if a[i] + a[j] > a[k]:
res += 1
print(res) | p02583 |
from sys import setrecursionlimit
setrecursionlimit(3 * 10 ** 5)
class Node:
def __init__(self, id):
self.id = id
self.children = []
self.block_id_set = set()
def add_child(self, node):
self.children.append(node)
def add_block(self, id):
self.block_id_set.add(id)
def mai... | from sys import setrecursionlimit
setrecursionlimit(3 * 10 ** 5)
def main():
n, m, k = map(int, input().split(' '))
nodes = tuple([([], set()) for i in range(n)])
for _ in range(m):
a, b = sorted(map(lambda x: int(x) - 1, input().split()))
nodes[a][0].append(b)
nodes[b][0].append(a)
f... | p02762 |
n,m,k=list(map(int,input().split()))
class UF():
def __init__(self, N):
self._parent=[n for n in range(0, N)]
self._size=[1] * N
def find_root(self, x):
if self._parent[x]==x:return x
self._parent[x]=self.find_root(self._parent[x])
return self._parent[x]
def unite(self, x, y):
... | import sys
input=sys.stdin.readline
n,m,k=list(map(int,input().split()))
class UF():
def __init__(self, N):
self._parent=[n for n in range(0, N)]
self._size=[1] * N
def find_root(self, x):
if self._parent[x]==x:return x
self._parent[x]=self.find_root(self._parent[x])
return self._p... | p02762 |
import sys
input=sys.stdin.readline
n,m,k=list(map(int,input().split()))
class UF():
def __init__(self, N):
self._parent=[n for n in range(0, N)]
self._size=[1] * N
def find_root(self, x):
if self._parent[x]==x:return x
self._parent[x]=self.find_root(self._parent[x])
return self._p... | import sys
input=sys.stdin.readline
n,m,k=list(map(int,input().split()))
class UF():
def __init__(self, N):
self._parent=[n for n in range(0, N)]
self._size=[1] * N
def find_root(self, x):
if self._parent[x]==x:return x
self._parent[x]=self.find_root(self._parent[x])
return self._p... | p02762 |
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):
... | 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):
... | p02762 |
import sys
sys.setrecursionlimit(10**9)
N, M, K = list(map(int, input().split()))
G = [[] for _ in range(N)]
AB = []
for _ in range(M):
a, b = list(map(int, input().split()))
G[a-1].append(b-1)
G[b-1].append(a-1)
AB.append((a-1, b-1))
H = [[] for _ in range(N)]
for _ in range(K):
c, ... | #Union Find
#xの根を求める
def find(x):
if par[x] < 0:
return x
else:
par[x] = find(par[x])
return par[x]
#xとyの属する集合の併合
def unite(x,y):
x = find(x)
y = find(y)
if x == y:
return False
else:
#sizeの大きいほうがx
if par[x] > par[y]:
... | p02762 |
# coding: utf-8
import sys
sysread = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10**7)
def run():
N,M,K = list(map(int,sysread().split()))
to = [[] for _ in range(N+1)]
n_to = [0 for _ in range(N + 1)]
for i in range(1,M+1):
a,b = list(map(int, sysre... | # coding: utf-8
import sys
sysread = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10**7)
def run():
N,M,K = list(map(int,sysread().split()))
to = [[] for _ in range(N+1)]
n_to = [0 for _ in range(N + 1)]
for i in range(1,M+1):
a,b = list(map(int, sysre... | p02762 |
class UnionFind:
def __init__(self, n):
self.t = [-1] * (n + 1)
def flatten(self):
for i, _ in enumerate(self.t):
self.find_root(i)
def union(self, a, b):
ra = self.find_root(a)
rb = self.find_root(b)
if ra != rb:
self.t[max(ra,... | class UnionFind:
def __init__(self, n):
self.t = [-1] * (n + 1)
def flatten(self):
for i, _ in enumerate(self.t):
self.find_root(i)
def union(self, a, b):
ra = self.find_root(a)
rb = self.find_root(b)
if ra != rb:
self.t[max(ra,... | p02762 |
class UnionFind:
def __init__(self, n):
self.t = [-1] * (n + 1)
def flatten(self):
for i, _ in enumerate(self.t):
self.find_root(i)
def union(self, a, b):
ra = self.find_root(a)
rb = self.find_root(b)
if ra != rb:
self.t[max(ra,... | class UnionFind:
def __init__(self, n):
self.t = [-1] * (n + 1)
def flatten(self):
for i, _ in enumerate(self.t):
self.find_root(i)
def union(self, a, b):
ra = self.find_root(a)
rb = self.find_root(b)
if ra != rb:
self.t[max(ra,... | p02762 |
from heapq import heappop, heappush
from collections import Counter
N, M, K = list(map(int, input().split()))
G = [[] for _ in range(N)]
deg = [0 for _ in range(N)]
reds = [[] for _ in range(N)]
for _ in range(M):
_a, _b = list(map(int, input().split()))
_a -= 1
_b -= 1
G[_a].append(_b)
... | from heapq import heappop, heappush
from collections import Counter
N, M, K = list(map(int, input().split()))
G = [[] for _ in range(N)]
deg = [0 for _ in range(N)]
reds = [[] for _ in range(N)]
for _ in range(M):
_a, _b = list(map(int, input().split()))
_a -= 1
_b -= 1
G[_a].append(_b)
... | p02762 |
#n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
def __init__(self, n):
self.size = n
self.par = [i for i in range(n)]
self.rank = [0]*n
self.size = [1]*n
def root(self, x):
if self.par[x] != x... | #n = int(input())
#s = input()
#n, k= map(int,input().split())
#da = list(map(int,input().split()))
class UnionFind:
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0]*n
self.size = [1]*n
def root(self, x):
if self.par[x] != x:
self.par... | p02762 |
class union():
def __init__(self, n):
self.n = n
self.par = [i for i in range(n)]
self.rank = [0] * n
self.friends = [0 for i in range(n)]
self.blocks = [[] for i in range(n)]
self.counts = [1] * n
self.block_counts = [0] * n
def find(self, n):
... | class union():
def __init__(self, n):
self.n = n
self.par = [i for i in range(n)]
self.rank = [0] * n
self.friends = [0 for i in range(n)]
self.blocks = [[] for i in range(n)]
self.counts = [1] * n
self.block_counts = [0] * n
def find(self, n):
... | p02762 |
class UnionFind:
# この時点でそれぞれのノードは自分を親としている
# 初期化時に問題が0の頂点を認めるかに注意すること
def __init__(self, n):
self.N = n
self.parent = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
# xの根を返す関数
def root(self, x):
visited_nodes = []
while True:
... | from sys import stdin
input = stdin.readline
class UnionFind:
# この時点でそれぞれのノードは自分を親としている
# 初期化時に問題が0の頂点を認めるかに注意すること
def __init__(self, n):
self.N = n
self.parent = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
# xの根を返す関数
def root(self, x):
vi... | p02762 |
from collections import deque
n, m, k =list(map(int, input().split()))
g = []
# Init Graph
for _ in range(n):
g.append(deque(list()))
bd = dict()
fd = dict()
directcount = [0] * n
for i in range(m):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
g[a].append(b)
... | class UnionFind():
# 作りたい要素数nで初期化
# 使用するインスタンス変数の初期化
def __init__(self, n):
self.n = n
# root[x]<0ならそのノードが根かつその値が木の要素数
# rootノードでその木の要素数を記録する
self.root = [-1] * (n + 1)
# 木をくっつける時にアンバランスにならないように調整する
self.rnk = [0] * (n + 1)
# ノードxのrootノードを見つける... | p02762 |
def main():
import sys
from collections import defaultdict
N, M, K = map(int, sys.stdin.readline().split())
F = [set() for _ in range(N)]
B = [set() for _ in range(N)]
for m in range(M):
a, b = map(int, sys.stdin.readline().split())
a, b = a - 1, b - 1
F[a].add... | def main():
import sys
from collections import defaultdict
N, M, K = map(int, sys.stdin.readline().split())
F = [set() for _ in range(N)]
B = [set() for _ in range(N)]
for m in range(M):
a, b = map(int, sys.stdin.readline().split())
a, b = a - 1, b - 1
F[a].add... | p02762 |
from collections import deque, defaultdict
N, M, K = list(map(int, input().split()))
repn = [[] for _ in range(N + 1)]
repnNum = [0] * (N + 1)
for _ in range(M):
a, b = list(map(int, input().split()))
repn[a].append(b)
repn[b].append(a)
repnNum[a] += 1
repnNum[b] += 1
block = [[] for _... | class UnionFind():
"""
https://note.nkmk.me/python-union-find/
DFSの上位互換と考えて良い
2要素x, yがpath-connectedかどうかをlogオーダーで判定する(螺旋本の14.1節参照)
さらに連結成分の要素数がO(1)で取得可能なように改造してある
"""
def __init__(self, n):
"""
要素数をnとして、各ノードを0,1,...,(n-1)の番号で管理する
parentsは各ノードの属する木の根を表す
... | p02762 |
class DisjointSet:
def __init__(self, size):
self.rank = [0 for i in range(size)]
self.p = [0 for i in range(size)]
for i in range(size):
self.makeSet(i)
def makeSet(self, x):
self.p[x] = x
self.rank[x] = 0
def same(self, x, y):
r... | class DisjointSet:
def __init__(self, size):
self.rank = [0 for i in range(size)]
self.p = [0 for i in range(size)]
for i in range(size):
self.makeSet(i)
def makeSet(self, x):
self.p[x] = x
self.rank[x] = 0
def same(self, x, y):
r... | p02762 |
def root(parents, i):
depth = 0
while parents[i] != i:
i = parents[i]
depth += 1
return i, depth
def isSame(parents, a, b):
return root(parents,a)[0] == root(parents, b)[0]
def union(parents, size, a, b):
pa, deptha = root(parents, a)
pb, depthb = root(parents, b)... | def root(parents, i):
depth = 0
while parents[i] != i:
i = parents[i]
depth += 1
return i, depth
def isSame(parents, a, b):
return root(parents,a)[0] == root(parents, b)[0]
def union(parents, size, a, b):
pa, deptha = root(parents, a)
pb, depthb = root(parents, b)... | p02762 |
n,m,k = list(map(int,input().split()))
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
A = []
B = []
while a != pre[a]:
a = pre[a]
A.append(a)
while b != pre[b]:
b = pre[b]
... | n,m,k = list(map(int,input().split()))
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
A = [a]
B = [b]
la = 1
lb = 1
while a != pre[a]:
a = pre[a]
A.append(a)
la += 1
... | p02762 |
n,m,k = list(map(int,input().split()))
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
A = [a]
B = [b]
la = 1
lb = 1
while a != pre[a]:
a = pre[a]
A.append(a)
la += 1
... | n,m,k = list(map(int,input().split()))
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
A = [a]
B = [b]
la = 1
lb = 1
while a != pre[a]:
a = pre[a]
A.append(a)
la += 1
... | p02762 |
#01:55
#UnionFind最適化に向けた実験
n,m,k = list(map(int,input().split()))
cnt = [1 for _ in range(n)]
pre = [i for i in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
A = []
B = []
while a != pre[a]:
a = pre[... | #02:08
#BFS
n,m,k = list(map(int,input().split()))
peer = [[] for _ in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
a,b = list(map(int,input().split()))
a -= 1
b -= 1
num[a] += 1
num[b] += 1
peer[a].append(b)
peer[b].append(a)
seen = [0 for _ in range(n)]
root = [i for i in range... | p02762 |
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):
... | 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):
... | p02762 |
import sys
input = sys.stdin.readline
from collections import deque
import copy
N, M, K = list(map(int, input().split()))
friend = [deque() for _ in range(N)]
status = [-1]*N
numList = [0]*N
for _ in range(M):
a, b = list(map(int, input().split()))
friend[a-1].append(b-1)
friend[b-1].append(a... | import sys
input = sys.stdin.readline
from collections import deque
import copy
N, M, K = list(map(int, input().split()))
friend = [deque() for _ in range(N)]
status = [-1]*N
numList = [0]*N
ans = [0]*N
for _ in range(M):
a, b = list(map(int, input().split()))
friend[a-1].append(b-1)
friend[... | p02762 |
from collections import deque
import sys
input = sys.stdin.readline
def connected_components(graph):
seen = set()
def component(n):
nodes = set([n])
while nodes:
n = nodes.pop()
seen.add(n)
nodes |= set(graph[n]) - seen
yield n
for n in graph:
if n not in seen:
... | import sys
input = sys.stdin.readline
def connected_components(graph):
seen = set()
def component(n):
nodes = set([n])
while nodes:
n = nodes.pop()
seen.add(n)
nodes |= graph[n] - seen
yield n
for n in graph:
if n not in seen:
yield component(n)
n,m,k=li... | p02762 |
# import sys
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import copy
# import bisect
# import numpy as np
# from scipy.special import comb
# def my_input(): return sys.stdin.readline().rstrip()
# sys.setrecursionlimit(100000)
# IN... | 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):
... | p02762 |
# coding: utf-8
from sys import setrecursionlimit
def dfs(node: int):
if checked[node]:
return
checked[node] = True
chain.add(node)
for n in friends[node]:
dfs(n)
def solve(*args: str) -> str:
setrecursionlimit(2 * 10 ** 9)
n, m, k = list(map(int, args[0].spl... | # coding: utf-8
def solve(*args: str) -> str:
n, m, k = list(map(int, args[0].split()))
friends = [set() for _ in range(n+1)]
blocked = [set() for _ in range(n+1)]
for a, b in map(str.split, args[1:1+m]):
friends[int(a)].add(int(b))
friends[int(b)].add(int(a))
for c... | p02762 |
class UnionFind:
def __init__(self, size):
self.parents = [x for x in range(size)]
self.sizes = [1] * size
def unite(self, a, b):
if self.find(a) == self.find(b):
return
if self.size_of(a) > self.size_of(b):
self.sizes[self.find(a)] += self.size_of(b)
self.parent... | import sys
sys.setrecursionlimit(2 ** 30)
N, M, K = list(map(int, input().split()))
groups = [None] * N
visited = set()
# 連結成分を求める
def dfs(group, i):
if i in visited:
return
visited.add(i)
group.add(i)
groups[i] = group
# 他のノード
for c in graph[i]:
if not c in visited:
dfs... | p02762 |
from collections import deque
class Graph:
# n is the number of N
# E is a set of edges where each edge is a two tuple (u, v)
def __init__(self, n, E):
self.N = n # number of vertices
self.V = list(range(0, n)) # V = [0, 1, ..., n-1]
self.AL = [set() for i in range(n)] # adj... | # Union-Find木(サイズ付き)
class UnionFind():
# 初めは全ての頂点が別々の木の根
def __init__(self, n): # n要素で初期化
self.parent = [None] * n # 親
self.rank = [None] * n # 木の深さ
self._size = [1] * n # 要素が属する集合の大きさ(根の要素のみ参照すること)
for i in range(n):
self.parent[i] = i
self.r... | p02762 |
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):
... | import sys
sys.setrecursionlimit(100000)
class UnionFind():
def __init__(self, n):
self.parents = [-1]*n
self.count = [1]*n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return... | p02762 |
N,M,K=list(map(int,input().split()))
fdic={}
for i in range(1,N+1):
fdic[i]=set()
for i in range(M):
a,b=list(map(int,input().split()))
fdic[a].add(b)
fdic[b].add(a)
bdic={}
for i in range(1,N+1):
bdic[i]=set()
for i in range(K):
c,d=list(map(int,input().split()))
bdic[c].add(d)
bdic[d... | N,M,K=list(map(int,input().split()))
fdic={}
for i in range(1,N+1):
fdic[i]=set()
for i in range(M):
a,b=list(map(int,input().split()))
fdic[a].add(b)
fdic[b].add(a)
blist=[]
for i in range(K):
c,d=list(map(int,input().split()))
blist.append((c,d))
#print(fdic)
#print(blist)
dic_clus... | p02762 |
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(500000)
class UnionFind:
def __init__(self, n):
self.n = n
self.parent = [0] * (n+3)
self.num = [1] * (n+3)
self.diff_weight = [0] * (n+3)
for i in range(n):
self.parent[i] = i
... | import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(500000)
# class UnionFind:
# def __init__(self, n):
# self.n = n
# self.parent = [0] * (n+3)
# self.num = [1] * (n+3)
# self.diff_weight = [0] * (n+3)
# for i in range(n):
# self.p... | p02762 |
from collections import deque, Counter
N, M, K = list(map(int, input().split()))
F = [[0 for _ in range(N)] for _ in range(N)]
B = [[0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
F[a][b] = 1
F[b][a] = 1
for _ in range(K):
... | from collections import deque, Counter
N, M, K = list(map(int, input().split()))
F = [[] for _ in range(N)]
B = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
a -= 1
b -= 1
F[a].append(b)
F[b].append(a)
for _ in range(K):
a, b = list(map(int, inpu... | p02762 |
class UnionFind:
"""
parents: 各要素の親要素
要素がrootの場合には -(そのグループに属する要素数) を格納
"""
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
# xが属するグループのrootを取得
if self.parents[x] < 0:
return x
else:
... | 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):
... | p02762 |
from collections import defaultdict
from collections import deque
n,m,k = list(map(int,input().split()))
f_set = {tuple(map(int,input().split())) for _ in range(m)}
b_set = {tuple(map(int,input().split())) for _ in range(k)}
friends_counts = {key:[] for key in range(1,n+1)}
blocks_counts = {key:[] for k... | from collections import defaultdict
from collections import deque
n,m,k = list(map(int,input().split()))
f_set = {tuple(map(int,input().split())) for _ in range(m)}
b_set = {tuple(map(int,input().split())) for _ in range(k)}
friends_counts = {key:[] for key in range(1,n+1)}
blocks_counts = {key:[] for k... | p02762 |
import bisect
class UnionFind():
def __init__(self, n):
self.n = next
self.parent = [-1 for i in range(n)]
def find(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.find(self.parent[x])
return self... | import bisect
class UnionFind():
def __init__(self, n):
self.n = next
self.parent = [-1 for i in range(n)]
def find(self, x):
if self.parent[x] < 0:
return x
else:
self.parent[x] = self.find(self.parent[x])
return self... | p02762 |
from collections import deque
n,m,k=map(int,input().split())
fr=[[]]
for i in range(n-1):
fr.append([])
for i in range(m):
a,b=map(int,input().split())
fr[a-1].append(b)
fr[b-1].append(a)
belong=[0]*n
anslist=[0]*n
count=0
def bfs(k):
global count
if belong[k-1]==0:
count+=1
use=de... | from collections import deque
n,m,k=map(int,input().split())
fr=[[]]
for i in range(n-1):
fr.append([])
for i in range(m):
a,b=map(int,input().split())
fr[a-1].append(b)
fr[b-1].append(a)
belong=[0]*n
anslist=[0]*n
count=0
def bfs(k):
global count
if belong[k-1]==0:
count+=1
use=de... | p02762 |
from collections import defaultdict
from collections import Counter
N,M,K = map(int,input().split())
fn = defaultdict(lambda: 1)
CD = [0]*K
par = list(range(N))
def root(x):
S = set()
S.add(x)
y = x
while True:
if par[y] == y:
for s in S:
par[s] =... | from collections import defaultdict
from collections import Counter
N,M,K = map(int,input().split())
fn = [1]*N
CD = [0]*K
par = list(range(N))
def root(x):
S = set()
S.add(x)
y = x
while True:
if par[y] == y:
for s in S:
par[s] = y
r... | p02762 |
from collections import defaultdict
from collections import Counter
N,M,K = map(int,input().split())
fn = [1]*N
CD = [0]*K
par = list(range(N))
def root(x):
S = set()
S.add(x)
y = x
while True:
if par[y] == y:
for s in S:
par[s] = y
r... | # ABC157 - D
from collections import Counter
N,M,K = map(int,input().split())
fn = [1]*N
CD = [0]*K
par = list(range(N))
def root(x):
S = set()
S.add(x)
y = x
while True:
if par[y] == y:
for s in S:
par[s] = y
return y
S.ad... | p02762 |
def main():
from collections import deque
import sys
input = sys.stdin.readline
N,M,K = list(map(int, input().split()))
ans = [0]*N
table = [[] for i in range(N)]
visited = [0]*N
block = [[] for i in range(N)]
groups = [[] for i in range(N)]
for i in range(M):
... | def main():
from collections import deque
import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
ans = [0] * N
table = [[] for i in range(N)]
visited = [0] * N
block = [[] for i in range(N)]
for i in range(M):
a, b = list(map(int, input(... | p02762 |
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):
... | 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):
... | p02762 |
def solve():
from collections import Counter
import sys
input = sys.stdin.readline
N, M, K = list(map(int, input().split()))
ABs = [tuple(map(int, input().split())) for _ in range(M)]
CDs = [tuple(map(int, input().split())) for _ in range(K)]
# Union-Findデータ構造
class UnionFind... | import sys
input = sys.stdin.readline
class UnionFind:
def __init__(self, numV):
self.pars = list(range(numV))
self.ranks = [0] * numV
self.sizes = [1] * numV
def getRoot(self, x):
par = self.pars[x]
if par != x:
self.pars[x] = par = self.getRoot(p... | p02762 |
from collections import defaultdict
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 s... | from collections import defaultdict
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 s... | p02762 |
class UnionFind:
def __init__(self, n):
self.p, self.d = [-1] * n, [0] * n
def find(self, x):
if self.p[x] < 0:
return x
else:
self.p[x] = self.find(self.p[x])
return self.p[x]
def isSame(self, x, y):
return self.find(x) == ... | class UnionFind:
def __init__(self, n):
self.p, self.d = [-1] * n, [0] * n
def find(self, x):
if self.p[x] < 0:
return x
else:
self.p[x] = self.find(self.p[x])
return self.p[x]
def isSame(self, x, y):
return self.find(x) == ... | p02762 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | p02762 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | p02762 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | p02762 |
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | # -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, produc... | p02762 |
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
... | import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
... | p02762 |
N, M, K = list(map(int, input().split()))
p = [0] * N # p[][0] 友達リスト p[][1] ブロックリスト p[][2] 所属グループ(-1はなし)
for i in range(N):
p[i] = [0]*3
p[i][0] = []
p[i][1] = []
p[i][2] = -1
g = [] # グループのサイズ
stack = []
groupNum = 0
for i in range(M):
a, b = list(map(int, input().split()))
p[a-1]... | N, M, K = list(map(int, input().split()))
p = [0] * N # p[][0] 友達リスト p[][1] ブロックリスト p[][2] 所属グループ(-1はなし)
for i in range(N):
p[i] = [0]*3
p[i][0] = []
p[i][1] = []
p[i][2] = -1
g = [] # グループのサイズ
stack = []
groupNum = 0
fcs = []
for i in range(M):
a, b = list(map(int, input().split()))
... | p02762 |
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32
# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
def __init__(self, n):
# par = Parent Number or NoV
self.par = [-1] * (n+1)
# rank ... | #!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32
# refered to
# rank : http://at274.hatenablog.com/entry/2018/02/02/173000
# size : abc120 kaisetsu
class UnionFind:
def __init__(self, n):
# par = Parent Number or NoV
self.par = [-1] * (n+1)
# rank ... | p02762 |
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 = self.find(x)
y = self.find(y)
if x == y:
... | 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 = self.find(x)
y = self.find(y)
if x == y:
... | p02762 |
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
return [ int(input()) for _ in range(n)]
... | import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
return [ int(s) for s in input().split(" ")]
# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
return [ int(input()) for _ in range(n)]
... | p02762 |
N, M, K = map(int, input().split())
par = list(range(N))
siz = [1] * N
n_friend = [0] * N
def root(x):
if par[x] == x:
return x
else:
par[x] = root(par[x])
return par[x]
def same(x, y):
return root(x) == root(y)
def unite(x, y):
x = root(x)
y = root(... | class UnionFind:
def __init__(self, n):
self.par = list(range(n)) # self.par[x] = y: xの属する木の根はy
self.siz = [1] * n
def root(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.root(self.par[x])
return self.par[x]
... | p02762 |
N,M,K = list(map(int, input().split()))
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 sel... | N,M,K = list(map(int, input().split()))
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 sel... | p02762 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.