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

25263번 - Stranded Far From Home 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB69312946.032%

문제

You just couldn’t leave it alone… You actually carried out the break-in, and initially everything worked out as planned. However, the communication with your assistant went terribly wrong.* Instead of returning safely to Lübeck, you are now stranded on a small island, and your submarine is out of fuel.

To return in time for the BOI award ceremony, you now have to get to the ferry on the other side of the island. However, the local population has strange traditions. Ties are very important to them, and every village has its own preferred tie color which might change over time.

A report from the internet tells you that different villages initially preferred different tie colors. Unfortunately, the report is quite outdated. Since then, every week exactly one village convinced a neighboring village to prefer the same tie color as them. (Two villages are neighbors if they are directly connected by a road.) However, this can only happen if there were at least as many people on the entire island who preferred the tie color of the first village as there were people who preferred the tie color of the second village. Enough time has passed so that all islanders now prefer the same tie color.

You are almost sure that the islanders won’t let you pass if you don’t wear a tie matching their preference. To get to the ferry, you therefore plan to wear a tie of every color that the islanders could prefer. However, wearing too many ties will make you look suspicious. Write a program that uses a description of the island to calculate which ties you have to wear.


* That was to be expected, right?

입력

The first line of the input contains two integers $N$ and $M$ where $N$ is the number of villages and $M$ is the number of roads on the island. The villages are numbered from 1ドル$ to $N$.

The next line contains $N$ integers $s_1, \dots , s_N$ where $s_i$ describes the number of inhabitants of village $i$.

Each of the following $M$ lines contains two integers $a$ and $b$ (1ドル ≤ a, b ≤ N,ドル $a \ne b$), meaning that there is a road between villages $a$ and $b$. All villages are connected to each other at least indirectly.

출력

Your program should output a string of length $N$ consisting of 0s and 1s. The $i$-th digit should be 1 if and only if it is possible that all islanders now prefer the tie color that village $i$ preferred initially.

제한

It always holds that 1ドル ≤ N ≤ 200,000円,ドル 0ドル ≤ M ≤ 200,000円,ドル and 1ドル ≤ s_i ≤ 10^9$.

서브태스크

번호배점제한
110

$N ≤ 2,000円$ and $M ≤ 2,000円$.

210

$s_1 ≥ \dots ≥ s_N,ドル and every village $b$ with $b > 1$ is directly connected to exactly one village $a$ with $a < b$.

315

Villages $a$ and $b$ are directly connected if and only if $|a - b| = 1$.

430

There are at most 10ドル$ distinct numbers of inhabitants.

535

No further constraints.

예제 입력 1

4 4
2 2 4 3
1 2
1 3
2 3
3 4

예제 출력 1

1110

예제 입력 2

4 3
4 2 2 1
1 2
3 2
4 1

예제 출력 2

1110

힌트

The following picture shows the first example:

The first digit of the output is 1ドル$ since it is possible that all islanders now prefer the tie color that village 1ドル$ preferred initially. This could happen as follows: In the first week, village 1ドル$ convinces village 2ドル$ that their tie color is better. After that, there are four people who prefer the tie color of village 1ドル$. Therefore, village 1ドル$ can now convince village 3ドル$ of their tie color, and if afterwards village 3ドル$ convinces village 4ドル,ドル everybody prefers the tie color that village 1ドル$ preferred initially.

The last digit of the output is 0ドル$ since it is impossible that village 4ドル$ convinces anyone of their tie color. This is because village 4ドル$ is only connected to village 3ドル,ドル but village 3ドル$ has more inhabitants.

Note that the second example is a valid test case for the second subtask.

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2022 E번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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