RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00586

Alias

Unrated 레이팅 미적용
난이도
1s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Novak and Rafael are playing a simplified version of the game Alias. Novak needs to make Rafael guess
a word without saying it. Rafael has a database of \(n\) words in his head, and there are \(m\) connections
between some words. The connection between words \(x\) and \(y\), with time \(t\), means that if Rafael remembers
the word \(x\) or hears it, after \(t\) milliseconds he will remember the word \(y\).
Novak and Rafael will play \(q\) rounds. In each round, Novak wants to know: if he says the word \(a\), after
how many milliseconds will Rafael remember the word \(b\) for the first time? The rounds are independent.

제약

In test cases worth 20 points, it holds \(1 \le n \le 10\).
In test cases worth additional 20 points, it holds \(1 \le n \le 100\).

입력 형식

The first line contains integers \(n\) (\(2 \le n \le 1000\)) and \(m\) (\(1 \le m \le 1000\)), the number of words and the
number of connections.
Each of the following \(m\) lines contains two different words \(x@@RISE_MATH_BLOCK_0@@i\), and an integer \(t@@RISE_MATH_BLOCK_1@@i \le 10^{9}\)), that
describe a connection. The words consist of at most 20 lowercase letters. All words from Rafael’s database
will appear at least once. It is possible that there are multiple connections between some pairs of words.
The following line contains an integer \(q\) (\(1 \le q \le 1000\)), the number of rounds.
Each of the following \(q\) lines contains two different words \(a@@RISE_MATH_BLOCK_2@@i\), the word that Novak will say and the
word that Rafael needs to remember in the \(i-th\) round. Both words appear in Rafael’s database.

출력 형식

Output \(q\) lines. In the \(i-th\) line output the time for the \(i-th\) round in milliseconds, or Roger if Rafael will
never remember the word.

예제 1
입력
3 2
novak goat 1
goat simulator 3
2
novak simulator
simulator goat
출력
4
Roger
예제 2
입력
3 3
kile legend 4
legend beer 5
beer kile 6
2
kile beer
legend kile
출력
9
11
예제 3
입력
4 5
rafael me 5
me ow 6
ow ausopenfinal 2012
ausopenfinal me 2
rafael ausopenfinal 2
3
rafael me
me rafael
ow me
출력
4
Roger
2014
문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2020/2021 Contest 6

평가 및 의견

Alias

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Alias

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