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

D. Game Strategy

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

의견: 0

설명

Alice and Bob are playing a board game. The board is divided into positions labeled a, b, c, d, . . . and the players use a gamepiece to mark the current position. Each round of the game consists of two steps: 1. Alice makes a choice. Depending on the current position, she has different options, where each option is a set of positions. Alice chooses one set \(S\) among the available sets of positions. 2. Bob makes a choice. His choice is one position \(p\) from the set \(S\) that Alice chose in step 1. Bob moves the gamepiece to position \(p\), which is the position for the start of the next round. Prior to the first round, each player independently selects one of the positions and reveals it at the start of the game. Bob’s position is where the game starts. Alice wins the game if she can force Bob to move the gamepiece to the position she has chosen. To make things interesting, they have decided that Bob will pay Alice a certain amount if he loses, but Alice must pay Bob a certain amount after every round. The game now ends if Alice’s position is reached or when Alice runs out of cash. Both Alice and Bob play optimally: Alice will always choose an option that will lead to her winning the game, if this is possible, and Bob will always try to prevent Alice from winning. For all possible start and end positions, Alice would like you to determine whether she can win the game and if so, how many rounds it will take.

제약
입력 형식

The input consists of a single test case. The first line contains the number of positions \(n\) (\(1 \le n \le 25\)). The \(n\) positions are labeled using the first \(n\) letters of the English alphabet in lowercase. The rest of the test case consists of \(n\) lines, one for each position \(p\), in alphabetical order. The line for position \(p\) contains the options available to Alice in position \(p\). It starts with the number of options \(m\) (\(1 \le m < 2^{n}\)), which is followed by \(m\) distinct strings, one for each option. Each string contains the positions available to Bob if Alice chooses that option. The string has at least 1 character, the characters (which correspond to valid board positions) are in alphabetical order, and no characters are duplicated. The total number of options for the test case is at most \(10^{6}\).

출력 형식

For each position \(p\) in alphabetical order, display one line. In that line, for each position \(q\) in alphabetical order display the minimal number of rounds in which Alice can be guaranteed to arrive at position \(q\) when starting the game in position \(p\), \(or - 1\) if Alice cannot be guaranteed to reach \(q\) from \(p\).

예제 1
입력
2
2 ab b
1 b
출력
0 1 
-1 0
예제 2
입력
3
1 b
2 b a
2 ab ac
출력
0 1 -1 
1 0 -1 
2 2 0
문제 정보

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

출처 ICPC World Finals 2014

평가 및 의견

D. Game Strategy

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

Log in to rate problems.

개별 의견

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

풀이 제출

D. Game Strategy

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