Skip to content

Commit 4b36391

Browse files
committed
🥺chore
1 parent 8e37cde commit 4b36391

File tree

8 files changed

+380
-6
lines changed

8 files changed

+380
-6
lines changed

acl1/a/main.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
class UnionFind:
40+
def __init__(self, N): self.N, self.group_count, self.root, self.rank = N, N, [-1] * N, [0] * N
41+
def __repr__(self): return str(self.all_groups())
42+
43+
def find(self, x):
44+
while self.root[x] >= 0: x = self.root[x]
45+
return x
46+
47+
def union(self, x, y):
48+
x, y = self.find(x), self.find(y)
49+
if x == y: return
50+
if self.rank[x] > self.rank[y]: x, y = y, x
51+
self.root[y] += self.root[x]
52+
self.root[x] = y
53+
if self.rank[x] == self.rank[y]: self.rank[y] += 1
54+
self.group_count -= 1
55+
56+
def same(self, x, y): return self.find(x) == self.find(y)
57+
def count(self, x): return -self.root[self.find(x)]
58+
def members(self, x): return [i for i in range(self.N) if self.same(x, i)]
59+
def roots(self): return [i for i, x in enumerate(self.root) if x < 0]
60+
def all_groups(self):
61+
d = defaultdict(lambda: [])
62+
for i in range(self.N): d[self.find(i)].append(i)
63+
return dict(d)
64+
65+
def main():
66+
N = I()
67+
xy = sorted(enumerate(LIR(N)), key=lambda x: x[1][0])
68+
ys = [y for _, (_, y) in xy]
69+
uf = UnionFind(N+1)
70+
71+
minYindex = 0
72+
for i in range(1, N):
73+
if ys[i] > ys[minYindex]:
74+
uf.union(xy[i][0], xy[minYindex][0])
75+
else:
76+
minYindex = i
77+
78+
for i in range(N):
79+
print(uf.count(i))
80+
81+
if __name__ == '__main__':
82+
main()

acl1/b/main.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
40+
41+
def main():
42+
N = I()
43+
44+
if __name__ == '__main__':
45+
main()

acl1/c/main.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
N = I()
41+
42+
if __name__ == '__main__':
43+
main()

acl1/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": "acl1",
4+
"title": "ACL Contest 1",
5+
"url": "https://atcoder.jp/contests/acl1"
6+
},
7+
"tasks": [
8+
{
9+
"id": "acl1_a",
10+
"label": "A",
11+
"title": "Reachable Towns",
12+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_a",
13+
"directory": {
14+
"path": "a",
15+
"testdir": "test",
16+
"submit": "main.py"
17+
}
18+
},
19+
{
20+
"id": "acl1_b",
21+
"label": "B",
22+
"title": "Sum is Multiple",
23+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_b",
24+
"directory": {
25+
"path": "b",
26+
"testdir": "test",
27+
"submit": "main.py"
28+
}
29+
},
30+
{
31+
"id": "acl1_c",
32+
"label": "C",
33+
"title": "Moving Pieces",
34+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_c",
35+
"directory": {
36+
"path": "c",
37+
"testdir": "test",
38+
"submit": "main.py"
39+
}
40+
},
41+
{
42+
"id": "acl1_d",
43+
"label": "D",
44+
"title": "Keep Distances",
45+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_d",
46+
"directory": {
47+
"path": "d",
48+
"testdir": "test",
49+
"submit": "main.py"
50+
}
51+
},
52+
{
53+
"id": "acl1_e",
54+
"label": "E",
55+
"title": "Shuffle Window",
56+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_e",
57+
"directory": {
58+
"path": "e",
59+
"testdir": "test",
60+
"submit": "main.py"
61+
}
62+
},
63+
{
64+
"id": "acl1_f",
65+
"label": "F",
66+
"title": "Center Rearranging",
67+
"url": "https://atcoder.jp/contests/acl1/tasks/acl1_f",
68+
"directory": {
69+
"path": "f",
70+
"testdir": "test",
71+
"submit": "main.py"
72+
}
73+
}
74+
]
75+
}

acl1/d/main.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
N = I()
41+
42+
if __name__ == '__main__':
43+
main()

acl1/e/main.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
N = I()
41+
42+
if __name__ == '__main__':
43+
main()

acl1/f/main.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
N = I()
41+
42+
if __name__ == '__main__':
43+
main()

0 commit comments

Comments
 (0)