Skip to content

Commit 5689b0f

Browse files
author
IsHYuhi
committed
add greens
1 parent 9bb06f0 commit 5689b0f

File tree

4 files changed

+72
-4
lines changed

4 files changed

+72
-4
lines changed

ABC/ABC133/D.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
n = int(input())
2+
a = list(map(int, input().split()))
3+
s = sum(a)
4+
5+
x = [0]*(n+1)
6+
x[0] = s- 2*sum(a[1::2])
7+
for i in range(n):
8+
x[i+1] = 2*a[i]-x[i]
9+
10+
print(' '.join(map(str, x[:-1])))

ABC/ABC134/D.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
n = int(input())
2+
a = list(map(int, input().split()))
3+
ra = sorted(a, reverse=True)
4+
ans = [0]*n
5+
for i in range(n)[::-1]:
6+
s = sum(ans[i::i+1])%2
7+
if s!=a[i]:
8+
ans[i] = 1
9+
else:
10+
ans[i] = 0
11+
12+
13+
print(sum(ans))
14+
15+
idxs = [idx for idx, v in enumerate(ans, 1) if v == 1]
16+
if idxs:
17+
print(' '.join(list(map(str, idxs))))

ABC/ABC138/D.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
n, q = map(int, input().split())
2+
3+
ab =[[] for _ in range(n)]
4+
for _ in range(n-1):
5+
a, b = map(int, input().split())
6+
ab[a-1].append(b-1)
7+
ab[b-1].append(a-1)
8+
9+
px = [list(map(int, input().split())) for _ in range(q)]
10+
costs = [0]*n
11+
for p, x in px:
12+
costs[p-1] += x
13+
14+
visited = [0]*n
15+
# parents = [float('inf')]*n
16+
# leaf = [0]*n
17+
counter = [0]*n
18+
stack = []
19+
def dfs(start):
20+
stack.append(start)
21+
while stack:
22+
idx = stack.pop()
23+
counter[idx] += costs[idx]
24+
visited[idx] = 1
25+
flg = False
26+
27+
for next in ab[idx]:
28+
if not visited[next]:
29+
# parents[next] = idx
30+
stack.append(next)
31+
counter[next] += counter[idx]
32+
flg = True
33+
34+
# if not flg:
35+
# leaf[idx] = 1
36+
37+
dfs(0)
38+
# print('visited', visited)
39+
# print('parents', parents)
40+
# print('leaf', leaf)
41+
print(' '.join(map(str, counter)))

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AtCoderの問題をpython3で解いたものになります。AC確認は行っ
88
## [AtCoder Beginner Contest](ABC)
99
| Problem A | Problem B | Problem C | Problem D | Problem E | Problem F |
1010
|:---:|:---:|:---:|:---:|:---:|:---:|
11-
|182/182 <img align="center" src="https://img.shields.io/badge/Completed!-green?style=for-the-badge"/>|182/182 <img align="center" src="https://img.shields.io/badge/Completed!-green?style=for-the-badge"/>|159/182|45/176|4/57|0/57|
11+
|182/182 <img align="center" src="https://img.shields.io/badge/Completed!-green?style=for-the-badge"/>|182/182 <img align="center" src="https://img.shields.io/badge/Completed!-green?style=for-the-badge"/>|159/182|48/176|4/57|0/57|
1212

1313

1414
### ABC001 - ABC041
@@ -93,12 +93,12 @@ AtCoderの問題をpython3で解いたものになります。AC確認は行っ
9393
[ABC130](ABC/ABC130)|[&check;](ABC/ABC130/A.py)|[&check;](ABC/ABC130/B.py)|[&check;](ABC/ABC130/C.py)|[&check;](ABC/ABC130/D.py)||||[ABC170](ABC/ABC170)|[&check;](ABC/ABC170/A.py)|[&check;](ABC/ABC170/B.py)|[&check;](ABC/ABC170/C.py)|[&check;](ABC/ABC170/D.py)|||
9494
|[ABC131](ABC/ABC131)|[&check;](ABC/ABC131/A.py)|[&check;](ABC/ABC131/B.py)|[&check;](ABC/ABC131/C.py)|[&check;](ABC/ABC131/D.py)||||[ABC171](ABC/ABC171)|[&check;](ABC/ABC171/A.py)|[&check;](ABC/ABC171/B.py)|[&check;](ABC/ABC171/C.py)|[&check;](ABC/ABC171/D.py)|[&check;](ABC/ABC171/E.py)||
9595
|[ABC132](ABC/ABC132)|[&check;](ABC/ABC132/A.py)|[&check;](ABC/ABC132/B.py)|[&check;](ABC/ABC132/C.py)|||||[ABC172](ABC/ABC172)|[&check;](ABC/ABC172/A.py)|[&check;](ABC/ABC172/B.py)|[&check;](ABC/ABC172/C.py)||||
96-
|[ABC133](ABC/ABC133)|[&check;](ABC/ABC133/A.py)|[&check;](ABC/ABC133/B.py)|[&check;](ABC/ABC133/C.py)|||||[ABC173](ABC/ABC173)|[&check;](ABC/ABC173/A.py)|[&check;](ABC/ABC173/B.py)|[&check;](ABC/ABC173/C.py)|[&check;](ABC/ABC173/D.py)|||
97-
|[ABC134](ABC/ABC134)|[&check;](ABC/ABC134/A.py)|[&check;](ABC/ABC134/B.py)|[&check;](ABC/ABC134/C.py)|||||[ABC174](ABC/ABC174)|[&check;](ABC/ABC174/A.py)|[&check;](ABC/ABC174/B.py)|[&check;](ABC/ABC174/C.py)|[&check;](ABC/ABC174/D.py)|||
96+
|[ABC133](ABC/ABC133)|[&check;](ABC/ABC133/A.py)|[&check;](ABC/ABC133/B.py)|[&check;](ABC/ABC133/C.py)|[&check;](ABC/ABC133/D.py)||||[ABC173](ABC/ABC173)|[&check;](ABC/ABC173/A.py)|[&check;](ABC/ABC173/B.py)|[&check;](ABC/ABC173/C.py)|[&check;](ABC/ABC173/D.py)|||
97+
|[ABC134](ABC/ABC134)|[&check;](ABC/ABC134/A.py)|[&check;](ABC/ABC134/B.py)|[&check;](ABC/ABC134/C.py)|[&check;](ABC/ABC134/D.py)||||[ABC174](ABC/ABC174)|[&check;](ABC/ABC174/A.py)|[&check;](ABC/ABC174/B.py)|[&check;](ABC/ABC174/C.py)|[&check;](ABC/ABC174/D.py)|||
9898
|[ABC135](ABC/ABC135)|[&check;](ABC/ABC135/A.py)|[&check;](ABC/ABC135/B.py)|[&check;](ABC/ABC135/C.py)|||||[ABC175](ABC/ABC175)|[&check;](ABC/ABC175/A.py)|[&check;](ABC/ABC175/B.py)|[&check;](ABC/ABC175/C.py)||||
9999
|[ABC136](ABC/ABC136)|[&check;](ABC/ABC136/A.py)|[&check;](ABC/ABC136/B.py)|[&check;](ABC/ABC136/C.py)|[&check;](ABC/ABC136/D.py)||||[ABC176](ABC/ABC176)|[&check;](ABC/ABC176/A.py)|[&check;](ABC/ABC176/B.py)|[&check;](ABC/ABC176/C.py)||||
100100
|[ABC137](ABC/ABC137)|[&check;](ABC/ABC137/A.py)|[&check;](ABC/ABC137/B.py)|[&check;](ABC/ABC137/C.py)|||||[ABC177](ABC/ABC177)|[&check;](ABC/ABC177/A.py)|[&check;](ABC/ABC177/B.py)|[&check;](ABC/ABC177/C.py)|[&check;](ABC/ABC177/D.py)|[&check;](ABC/ABC177/E.py)||
101-
|[ABC138](ABC/ABC138)|[&check;](ABC/ABC138/A.py)|[&check;](ABC/ABC138/B.py)|[&check;](ABC/ABC138/C.py)|||||[ABC178](ABC/ABC178)|[&check;](ABC/ABC178/A.py)|[&check;](ABC/ABC178/B.py)|[&check;](ABC/ABC178/C.py)|[&check;](ABC/ABC178/D.py)|||
101+
|[ABC138](ABC/ABC138)|[&check;](ABC/ABC138/A.py)|[&check;](ABC/ABC138/B.py)|[&check;](ABC/ABC138/C.py)|[&check;](ABC/ABC135/D.py)||||[ABC178](ABC/ABC178)|[&check;](ABC/ABC178/A.py)|[&check;](ABC/ABC178/B.py)|[&check;](ABC/ABC178/C.py)|[&check;](ABC/ABC178/D.py)|||
102102
|[ABC139](ABC/ABC139)|[&check;](ABC/ABC139/A.py)|[&check;](ABC/ABC139/B.py)|[&check;](ABC/ABC139/C.py)|[&check;](ABC/ABC139/D.py)||||[ABC179](ABC/ABC179/)|[&check;](ABC/ABC179/A.py)|[&check;](ABC/ABC179/B.py)|[&check;](ABC/ABC179/C.py)|[&check;](ABC/ABC179/D.py)|||
103103
|[ABC140](ABC/ABC140)|[&check;](ABC/ABC140/A.py)|[&check;](ABC/ABC140/B.py)|[&check;](ABC/ABC140/C.py)|||||[ABC180](ABC/ABC180/)|[&check;](ABC/ABC180/A.py)|[&check;](ABC/ABC180/B.py)|[&check;](ABC/ABC180/C.py)|[&check;](ABC/ABC180/D.py)|||
104104
|[ABC141](ABC/ABC141)|[&check;](ABC/ABC141/A.py)|[&check;](ABC/ABC141/B.py)|[&check;](ABC/ABC141/C.py)|||||[ABC181](ABC/ABC181/)|[&check;](ABC/ABC181/A.py)|[&check;](ABC/ABC181/B.py)|[&check;](ABC/ABC181/C.py)|[&check;](ABC/ABC181/D.py)|||

0 commit comments

Comments
 (0)