init
This commit is contained in:
commit
851751ea87
82 changed files with 2093 additions and 0 deletions
27
1F.py
Normal file
27
1F.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
n = int(input())
|
||||
edges = [input().strip() for _ in range(n - 1)]
|
||||
R_in = [0] * n
|
||||
R_out = [0] * n
|
||||
B_in = [0] * n
|
||||
B_out = [0] * n
|
||||
for i in range(n - 1):
|
||||
row = edges[i]
|
||||
for j_idx, color in enumerate(row):
|
||||
j = i + 1 + j_idx
|
||||
if color == 'R':
|
||||
R_out[i] += 1
|
||||
R_in[j] += 1
|
||||
else:
|
||||
B_out[i] += 1
|
||||
B_in[j] += 1
|
||||
t_mixed_x2 = 0
|
||||
s_in_out = 0
|
||||
for v in range(n):
|
||||
road_R = R_in[v] + R_out[v]
|
||||
road_B = B_in[v] + B_out[v]
|
||||
t_mixed_x2 += road_R * road_B
|
||||
s_in_out += R_in[v] * B_out[v] + B_in[v] * R_out[v]
|
||||
if t_mixed_x2 // 2 == s_in_out:
|
||||
print("YES")
|
||||
else:
|
||||
print("NO")
|
||||
Loading…
Add table
Add a link
Reference in a new issue