포럼
문제 COCI00477

Planinarenje

설명

Mirko and Slavko like to hike together. Mirko likes mountain peaks, and Slavko likes valleys.
Because of this, every time they climb to a peak, Slavko decides which valley they are going
to descend to, given that a trail exists to it. Similarly, in each valley, Mirko decides which
peak they are going to climb up to. It will never be possible to directly climb from one peak to
another, or to get from one valley to another valley. In order to make the hiking as fun as
possible, they never visit the same spot twice (whether it’s a peak or a valley). Once they
reach a spot that only leads to spots they’ve visited before, they call the mountain rangers to
pick them up. If the final spot is a peak, Mirko wins, and if it is a valley, Slavko wins.
Naturally, you must already know what your task is: If we assume that both of them play
optimally, who wins? Answer this question for all initial peaks.

제약

In test cases worth 30% of total points, it will hold \(1 \le N \le 10\) and \(1 \le M \le N \cdot N\).
In test cases worth an additional 20% of total points, for each two connected spots, there will
exist a unique path between them. In other words, the graph will be a forest.

입력 형식

The first line contains two positive integers, \(N\) and \(M\) (\(1 \le N \le 5000\), \(1 \le M \le mi\)n(5000, \(N \cdot N\))).
Here \(N\) denotes the number of peaks and valleys (therefore, there are \(N\) peaks and \(N\)
valleys), and \(M\) denotes the number of hiking trails.
Each of the following \(M\) lines contains two positive integers: \(v_{i}\) and \(d_{i}\) (\(1 \le v_{i}\), \(d_{i} \le N\)) that
denote there is a trail between peak \(v_{i}\) and valley \(d_{i}\).
Between each peak and valley, there will exist at most one trail.

출력 형식

You must output \(N\) lines. The \(i^{th}\) line denotes the winner if the starting point is peak \(i\).

예제 1
입력
2 3
1 2
2 2
2 1
출력
Slavko
Slavko
예제 2
입력
4 5
2 2
1 2
1 1
1 3
4 2
출력
Slavko
Mirko
Mirko
Mirko
예제 3
입력
4 5
1 2
1 3
2 2
2 3
4 1
출력
Slavko
Slavko
Mirko
Slavko
문제 정보

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

출처 COCI 2017/2018 Contest 5

평가 및 의견

Planinarenje

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

Log in to rate problems.

개별 의견

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

풀이 제출

Planinarenje

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