RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0425 파일 입출력

Cowntact Tracing

Silver I 실버 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Farmer John is worried for the health of his cows (conveniently numbered
\(1 \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)\), meaning that at time \(t\), cow \(x\) shook hooves with cow \(y\).
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 \(K\)
hoof shakes (possibly including the same partner cow several times). After
shaking hooves \(K\) 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 \(N\) cows is patient zero,
nor does he know the value of \(K\)! Please help him narrow down the
possibilities for these unknowns based on his data. It is guaranteed that at
least one possibility is valid.

Problem credits: Brian Dean

제약

Problem credits: Brian Dean

입력 형식

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

출력 형식

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

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 tracing.in
출력을 쓸 파일 tracing.out
예제 1
입력
4 3
1100
7 1 2
5 2 3
6 2 4
출력
1 1 Infinity
설명

The only candidate for patient zero is cow 1. For all \(K>0\), cow 1 infects cow 2
at time 7, while cows 3 and 4 remain uninfected.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2019-2020 > US Open > Bronze

태그

평가 및 의견

Cowntact Tracing

개요
출제자 난이도 Silver I 실버 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Cowntact Tracing

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8