Skip to content

Commit ac4133c

Browse files
committed
chore
1 parent b3f4202 commit ac4133c

File tree

13 files changed

+501
-85
lines changed

13 files changed

+501
-85
lines changed

abc177/_abc177/a/main.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!usr/bin/env python3
2+
from collections import defaultdict, deque, Counter, OrderedDict
3+
from bisect import bisect_left, bisect_right
4+
from functools import reduce, lru_cache
5+
from heapq import heappush, heappop, heapify
6+
7+
import itertools
8+
import math, fractions
9+
import sys, copy
10+
11+
def L(): return sys.stdin.readline().split()
12+
def I(): return int(sys.stdin.readline().rstrip())
13+
def SL(): return list(sys.stdin.readline().rstrip())
14+
def LI(): return [int(x) for x in sys.stdin.readline().split()]
15+
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
16+
def LS(): return [list(x) for x in sys.stdin.readline().split()]
17+
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
18+
def LR(n): return [L() for _ in range(n)]
19+
def IR(n): return [I() for _ in range(n)]
20+
def LIR(n): return [LI() for _ in range(n)]
21+
def LIR1(n): return [LI1() for _ in range(n)]
22+
def SR(n): return [SL() for _ in range(n)]
23+
def LSR(n): return [LS() for _ in range(n)]
24+
25+
def perm(n, r): return math.factorial(n) // math.factorial(r)
26+
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
27+
28+
def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]
29+
30+
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
31+
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
32+
alphabets = "abcdefghijklmnopqrstuvwxyz"
33+
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34+
MOD = 1000000007
35+
INF = float("inf")
36+
37+
sys.setrecursionlimit(1000000)
38+
39+
def main():
40+
D, T, S = LI()
41+
print("Yes" if D <= T * S else "No")
42+
43+
if __name__ == '__main__':
44+
main()

abc177/_abc177/b/main.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!usr/bin/env python3
2+
from collections import defaultdict, deque, Counter, OrderedDict
3+
from bisect import bisect_left, bisect_right
4+
from functools import reduce, lru_cache
5+
from heapq import heappush, heappop, heapify
6+
7+
import itertools
8+
import math, fractions
9+
import sys, copy
10+
11+
def L(): return sys.stdin.readline().split()
12+
def I(): return int(sys.stdin.readline().rstrip())
13+
def SL(): return list(sys.stdin.readline().rstrip())
14+
def LI(): return [int(x) for x in sys.stdin.readline().split()]
15+
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
16+
def LS(): return [list(x) for x in sys.stdin.readline().split()]
17+
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
18+
def LR(n): return [L() for _ in range(n)]
19+
def IR(n): return [I() for _ in range(n)]
20+
def LIR(n): return [LI() for _ in range(n)]
21+
def LIR1(n): return [LI1() for _ in range(n)]
22+
def SLR(n): return [SL() for _ in range(n)]
23+
def LSR(n): return [LS() for _ in range(n)]
24+
25+
def perm(n, r): return math.factorial(n) // math.factorial(r)
26+
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
27+
28+
def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if args else [default for _ in range(n)]
29+
30+
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
31+
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
32+
alphabets = "abcdefghijklmnopqrstuvwxyz"
33+
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34+
MOD = 1000000007
35+
INF = float("inf")
36+
37+
sys.setrecursionlimit(1000000)
38+
39+
def main():
40+
S = SL()
41+
T = SL()
42+
43+
ans = INF
44+
for i in range(len(S)-len(T)+1):
45+
cnt = 0
46+
for j in range(len(T)):
47+
if S[i+j] != T[j]:
48+
cnt += 1
49+
ans = min(ans, cnt)
50+
print(ans)
51+
52+
if __name__ == '__main__':
53+
main()

abc177/_abc177/c/main.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!usr/bin/env python3
2+
from collections import defaultdict, deque, Counter, OrderedDict
3+
from bisect import bisect_left, bisect_right
4+
from functools import reduce, lru_cache
5+
from heapq import heappush, heappop, heapify
6+
7+
import itertools
8+
import math, fractions
9+
import sys, copy
10+
11+
def L(): return sys.stdin.readline().split()
12+
def I(): return int(sys.stdin.readline().rstrip())
13+
def SL(): return list(sys.stdin.readline().rstrip())
14+
def LI(): return [int(x) for x in sys.stdin.readline().split()]
15+
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
16+
def LS(): return [list(x) for x in sys.stdin.readline().split()]
17+
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
18+
def LR(n): return [L() for _ in range(n)]
19+
def IR(n): return [I() for _ in range(n)]
20+
def LIR(n): return [LI() for _ in range(n)]
21+
def LIR1(n): return [LI1() for _ in range(n)]
22+
def SR(n): return [SL() for _ in range(n)]
23+
def LSR(n): return [LS() for _ in range(n)]
24+
25+
def perm(n, r): return math.factorial(n) // math.factorial(r)
26+
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
27+
28+
def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]
29+
30+
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
31+
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
32+
alphabets = "abcdefghijklmnopqrstuvwxyz"
33+
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
34+
MOD = 1000000007
35+
INF = float("inf")
36+
37+
sys.setrecursionlimit(1000000)
38+
39+
def main():
40+
N = I()
41+
A = LI()
42+
cum = list(itertools.accumulate(A))
43+
ans = 0
44+
45+
for i in range(N):
46+
ans = (ans + A[i] * (cum[-1] - cum[i])) % MOD
47+
print(ans % MOD)
48+
49+
if __name__ == '__main__':
50+
main()

abc177/_abc177/contest.acc.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"contest": {
3+
"id": "abc177",
4+
"title": "AtCoder Beginner Contest 177",
5+
"url": "https://atcoder.jp/contests/abc177"
6+
},
7+
"tasks": [
8+
{
9+
"id": "abc177_a",
10+
"label": "A",
11+
"title": "Don't be late",
12+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_a",
13+
"directory": {
14+
"path": "a",
15+
"testdir": "test",
16+
"submit": "main.py"
17+
}
18+
},
19+
{
20+
"id": "abc177_b",
21+
"label": "B",
22+
"title": "Substring",
23+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_b",
24+
"directory": {
25+
"path": "b",
26+
"testdir": "test",
27+
"submit": "main.py"
28+
}
29+
},
30+
{
31+
"id": "abc177_c",
32+
"label": "C",
33+
"title": "Sum of product of pairs",
34+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_c",
35+
"directory": {
36+
"path": "c",
37+
"testdir": "test",
38+
"submit": "main.py"
39+
}
40+
},
41+
{
42+
"id": "abc177_d",
43+
"label": "D",
44+
"title": "Friends",
45+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_d",
46+
"directory": {
47+
"path": "d",
48+
"testdir": "test",
49+
"submit": "main.py"
50+
}
51+
},
52+
{
53+
"id": "abc177_e",
54+
"label": "E",
55+
"title": "Coprime",
56+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_e",
57+
"directory": {
58+
"path": "e",
59+
"testdir": "test",
60+
"submit": "main.py"
61+
}
62+
},
63+
{
64+
"id": "abc177_f",
65+
"label": "F",
66+
"title": "I hate Shortest Path Problem",
67+
"url": "https://atcoder.jp/contests/abc177/tasks/abc177_f",
68+
"directory": {
69+
"path": "f",
70+
"testdir": "test",
71+
"submit": "main.py"
72+
}
73+
}
74+
]
75+
}

abc177/_abc177/d/main.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!usr/bin/env python3
2+
from collections import defaultdict, deque, Counter, OrderedDict
3+
from bisect import bisect_left, bisect_right
4+
from functools import reduce, lru_cache
5+
from heapq import heappush, heappop, heapify
6+
7+
from itertools import *
8+
import math, fractions
9+
import sys, copy
10+
11+
def L(): return sys.stdin.readline().split()
12+
def I(): return int(sys.stdin.readline().rstrip())
13+
def SL(): return list(sys.stdin.readline().rstrip())
14+
def LI(): return [int(x) for x in sys.stdin.readline().split()]
15+
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
16+
def LS(): return [list(x) for x in sys.stdin.readline().split()]
17+
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
18+
def LR(n): return [L() for _ in range(n)]
19+
def IR(n): return [I() for _ in range(n)]
20+
def LIR(n): return [LI() for _ in range(n)]
21+
def LIR1(n): return [LI1() for _ in range(n)]
22+
def SLR(n): return [SL() for _ in range(n)]
23+
def LSR(n): return [LS() for _ in range(n)]
24+
25+
def perm(n, r): return math.factorial(n) // math.factorial(r)
26+
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))
27+
def powerset(iterable):
28+
s = list(iterable)
29+
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
30+
31+
def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if args else [default for _ in range(n)]
32+
33+
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
34+
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
35+
alphabets = "abcdefghijklmnopqrstuvwxyz"
36+
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
37+
MOD = 1000000007
38+
INF = float("inf")
39+
40+
sys.setrecursionlimit(1000000)
41+
42+
class UnionFind:
43+
def __init__(self, N): self.N, self.group_count, self.root, self.rank = N, N, [-1] * N, [0] * N
44+
def __repr__(self): return str(self.all_groups())
45+
46+
def find(self, x):
47+
while self.root[x] >= 0: x = self.root[x]
48+
return x
49+
50+
def union(self, x, y):
51+
x, y = self.find(x), self.find(y)
52+
if x == y: return
53+
if self.rank[x] > self.rank[y]: x, y = y, x
54+
self.root[y] += self.root[x]
55+
self.root[x] = y
56+
if self.rank[x] == self.rank[y]: self.rank[y] += 1
57+
self.group_count -= 1
58+
59+
def same(self, x, y): return self.find(x) == self.find(y)
60+
def count(self, x): return -self.root[self.find(x)]
61+
def members(self, x): return [i for i in range(self.N) if self.same(x, i)]
62+
def roots(self): return [i for i, x in enumerate(self.root) if x < 0]
63+
def all_groups(self):
64+
d = defaultdict(lambda: [])
65+
for i in range(self.N): d[self.find(i)].append(i)
66+
return dict(d)
67+
68+
def main():
69+
N, M = LI()
70+
AB = LIR1(M)
71+
uf = UnionFind(N)
72+
for a, b in AB: uf.union(a, b)
73+
74+
print(uf.all_groups())
75+
76+
if __name__ == '__main__':
77+
main()

0 commit comments

Comments
 (0)