#494
Silver III
Cowntact Tracing
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Farmer John is worried for the health of his cows (conveniently numbered 1N1 \ldots N as always) after an outbreak of the highly contagious bovine disease COWVID-19.

Recently, Farmer John tested all of his cows and found some of them to be positive for the disease. Using video footage from inside his barn, he is able to review recent interactions between pairs of cows --- it turns out that when cows greet each-other, they shake hooves, a gesture that can unfortunately spread the infection from one cow to another. Farmer John assembles a time-stamped list of interacting pairs of cows, with entries of the form (t,x,y)(t, x, y), meaning that at time tt, cow xx shook hooves with cow yy. Farmer John also knows the following:

(i) Exactly one cow on his farm could have started out carrying the disease (we'll call this cow "patient zero").

(ii) Once a cow is infected, she passes the infection along with her next KK hoof shakes (possibly including the same partner cow several times). After shaking hooves KK times, she no longer passes the infection along with subsequent hoof shakes (since at this point she realizes she is spreading the infection and washes her hooves carefully).

(iii) Once a cow is infected, she stays infected.

Unfortunately, Farmer John doesn't know which of his NN cows is patient zero, nor does he know the value of KK! Please help him narrow down the possibilities for these unknowns based on his data. It is guaranteed that at least one possibility is valid.

입력

The first line of the input file contains NN (2N1002 \leq N \leq 100) and TT (1T2501 \leq T \leq 250). The next line contains a string of length NN whose entries are 0s and 1s, describing the current state of Farmer John's NN cows --- 0 represents a healthy cow and 1 represents a cow presently with the disease. Each of the next TT lines describes a record in Farmer John's list of interactions and consists of three integers tt, xx, and yy, where tt is a positive integer time of the interaction (t250t \leq 250) and xx and yy are distinct integers in the range 1N1 \ldots N, indicating which cows shook hands at time tt. At most one interaction happens at each point in time.

출력

Print a single line with three integers xx, yy, and zz, where xx is the number of possible cows who could have been patient zero, yy is the smallest possible value of KK consistent with the data, and zz is the largest possible value of KK consistent with the data (if there is no upper bound on KK that can be deduced from the data, print "Infinity" for zz). Note that it might be possible to have K=0K=0.

예제 입력 1

4 3
1100
7 1 2
5 2 3
6 2 4

예제 출력 1

1 1 Infinity
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Silver III1명 투표· 약 1개월 전
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.