Skip to content

Commit

Permalink
Update 2024-04-29-alibaba-international-summer24-coding-test-0429.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyanshi committed Apr 29, 2024
1 parent 98b1bb2 commit ef28ecf
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,22 @@ BRB
比较简单,逐个判断所有边是不是一端黑一端红即可。通过100%。

```python
#
n = int(input())
color = input().strip()
b = set()
r = set()
for i, c in enumerate(color):
if c == "B":
b.add(i + 1)
else:
r.add(i + 1)

ans = 0
for _ in range(n - 1):
u, v = map(int, input().split())
if (u in b and v in r) or (u in r and v in b):
ans += 1
print(ans)
```

#### Correct Solution
Expand Down

0 comments on commit ef28ecf

Please sign in to comment.