Logo
(追記) (追記ここまで)

30325번 - Gadget Construction 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB203315.789%

문제

Grigory is a talented engineer who has a love in developing drones and, of course, geometry. As a skilled problem solver, he is able to come up with solutions in difficult situations, but today, he encountered a problem that his abilities alone are not enough to solve. Therefore, as his best sidekick, your task is to assist him.

There are $n$ cogs on the Cartesian plane. The $i$-th cog is located at the coordinates $(x_i,y_i)$ and has a character $c_i$ that describes its color – "b" means it is a black cog, while "w" means it is a white cog. In addition, no three cogs lie on the same line.

Grigory wants to build a gadget using some cogs. To do this, he first chooses a subset $S$ that consists of 4ドル$ or more of the $n$ cogs. Then, a loop of chains is placed around the cogs. The loop is chosen such that:

  • Every cog in $S$ either touches the loop or lies in its interior.
  • The total length of chains is minimal.

For example, the image below shows the chains that would be placed for a chosen set of cogs.

Finally, consider the cogs in $S$ that touch the loop. These are the most important cogs, so they cannot be interfering with each other. Therefore, any two adjacent cogs on the loop must have different colors, otherwise the resulting gadget won't be working properly. If a cog in $S$ does not touch the loop, then it may have an arbitrary color.

How many different sets $S$ can Grigory choose to build a properly working gadget? Since the answer can be very large, find the value modulo 10ドル^9+7$.

입력

The first line contains an integer $n$. Then $n$ lines follow. The $i$-th line contains two integers $x_i, y_i$ and a character $c_i$ denoting the coordinates and color of the $i$-th cog.

출력

Print the number of sets $S$ that satisfy the conditions modulo 10ドル^9+7$.

제한

  • 4ドル≤n≤500$
  • $-10^8≤x_i,y_i≤10^8$ for $i=1,2,\dots ,n$
  • $c_i∈\{$b, w$\}$ for $i=1,2,\dots ,n$
  • $(x_i, y_i) \ne (x_j,y_j)$ for $i \ne j$
  • No three cogs lie on the same line.

예제 입력 1

4
0 0 w
1 0 b
1 1 w
0 1 b

예제 출력 1

1

예제 입력 2

6
0 0 w
0 4 b
1 2 w
3 2 b
4 0 b
4 4 w

예제 출력 2

9

예제 입력 3

4
0 0 b
1 0 w
1 1 w
0 1 b

예제 출력 3

0

힌트

출처

ICPC > Regionals > Asia Pacific > Taiwan > Taiwan Online Programming Contest > TOPC 2023 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /