ICPC 2017 - B. Get a Clue!
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
Source-first archive entry
This page is built from the copied files in competitive_programming/icpc/2017/B-get-a-clue. Edit
competitive_programming/icpc/2017/B-get-a-clue/solution.tex to update the written solution and
competitive_programming/icpc/2017/B-get-a-clue/solution.cpp to update the implementation.
The website does not replace those files with hand-maintained HTML. It reads the copied source tree during the build and exposes the exact files below.
Problem Statement
Copied statement text kept beside the solution archive for direct reference.
Rapid City
event
sponsor
ICPC 2017
Problem B
Get a Clue!
Time limit: 4 seconds
Developed in the 1940s in the United Kingdom, the game of Cluedo is one of the most popular board games
in the world. The object of the game is to determine who murdered Mr. Body, which weapon was used
to murder him, and where the murder took place. The game uses a set of cards representing six persons
(labeled A, B, . . . , F), six weapons (labeled G, H, . . . , L) and nine rooms (labeled M, N, . . . , U). At the start
of the game, one person card, one weapon card, and one room card are selected at random and removed
from the deck so no one can see them – they represent the murderer, the murder weapon, and the murder
location. The remaining 18 cards are shuffled and dealt to the players, starting with player 1, then to her
right player 2, and so on. Some players may end up with one more card than others. For the purposes of this
problem there are four players, so the person to the right of player 4 is player 1.
The rest of the game is spent searching for clues. Players take turns, starting with player 1 and moving to
the right. A turn consists of making a suggestion (consisting of a murder suspect, a weapon, and a room)
and asking other players if they have any evidence that refutes the suggestion. For example, you might say
to another player “I believe the murderer was person A, using weapon L, in room T.” If the other player is
holding exactly one of these cards, that player must show you (and only you) that card. If they have more
than one such card, they can show you any one of them.
When making a suggestion, you must first ask the person to your right for any evidence. If they have none,
you continue with the person on their right, and so on, until someone has evidence, or no one has any of the
cards in your suggestion.
Many times you can gain information even if you are not the person making the suggestion. Suppose, in
the above example, you are the third player and have cards A and T. If someone else shows evidence to the
suggester, you know that it must be weapon card L. Keeping track of suggestions and who gave evidence at
each turn is an important strategy when playing the game.
To win the game, you must make an accusation, where you state your final guess of the murderer, weapon,
and room. After stating your accusation, you check the three cards that were set aside at the start of the
game – if they match your accusation, you win! Needless to say, you want to be absolutely sure of your
accusation before you make it.
Here is your problem. You are player 1. Given a set of cards dealt to you and a history of suggestions and
evidence, you need to decide how close you are to being able to make an accusation.
Input
The input starts with an integer n (1 ≤ n ≤ 50), the number of suggestions made during the game. Following
this is a line containing the five cards you are dealt, all uppercase letters in the range ‘A’. . . ‘U’. The remaining
n lines contain one suggestion per line. Each of these lines starts with three characters representing the
suggestion (in the order person, weapon, room), followed by the responses of up to three players, beginning
with the player to the right of the player making the suggestion. If a player presents no evidence, a ‘-’
(dash) is listed; otherwise an “evidence character” is listed. If the specific evidence card is seen by you
(either because you provided it or you were the person receiving the evidence) then the evidence character
Rapid City
event
sponsor
ICPC 2017
identifies that card; otherwise the evidence character is ‘*’. Note that only the last response can be an
evidence character. All characters are separated by single spaces. Only valid suggestion/response sequences
appear in the input.
Output
Display a three character string identifying the murderer, the murder weapon, and the room. If the murderer
can be identified, use the appropriate letter for that person; otherwise use ‘?’. Do the same for the murder
weapon and the room.
Sample Input 1 Sample Output 1
1 AGM
B I P C F
A G M - - -
Sample Input 2 Sample Output 2
2 E??
A B C D H
F G M M
F H M - *
Sample Input 3 Sample Output 3
3 ???
A C M S D
B G S - G
A H S - - S
C J S *
Editorial
Rendered from the copied solution.tex file. The original TeX source remains
available below.
Key Observations
Write the structural observations that make the problem tractable.
State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
If the constraints matter, explain exactly which part of the solution they enable.
Algorithm
Describe the data structures and the state maintained by the algorithm.
Explain the processing order and why it is sufficient.
Mention corner cases explicitly if they affect the implementation.
Correctness Proof
We prove that the algorithm returns the correct answer.
Lemma 1.
State the first key claim.
Proof.
Provide a concise proof.
Lemma 2.
State the next claim if needed.
Proof.
Provide a concise proof.
Theorem.
The algorithm outputs the correct answer for every valid input.
Proof.
Combine the lemmas and finish the argument.
Complexity Analysis
State the running time and memory usage in terms of the input size.
Implementation Notes
Mention any non-obvious implementation detail that is easy to get wrong.
Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
Code
Exact copied C++ implementation from solution.cpp.
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Source Files
Exact copied source-of-truth files. Edit solution.tex for the write-up and solution.cpp for the implementation.
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{enumitem}
\title{ICPC World Finals 2017\\B. Get a Clue!}
\author{}
\date{}
\begin{document}
\maketitle
\section*{Problem Summary}
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
\section*{Key Observations}
\begin{itemize}[leftmargin=*]
\item Write the structural observations that make the problem tractable.
\item State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
\item If the constraints matter, explain exactly which part of the solution they enable.
\end{itemize}
\section*{Algorithm}
\begin{enumerate}[leftmargin=*]
\item Describe the data structures and the state maintained by the algorithm.
\item Explain the processing order and why it is sufficient.
\item Mention corner cases explicitly if they affect the implementation.
\end{enumerate}
\section*{Correctness Proof}
We prove that the algorithm returns the correct answer.
\paragraph{Lemma 1.}
State the first key claim.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Lemma 2.}
State the next claim if needed.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Theorem.}
The algorithm outputs the correct answer for every valid input.
\paragraph{Proof.}
Combine the lemmas and finish the argument.
\section*{Complexity Analysis}
State the running time and memory usage in terms of the input size.
\section*{Implementation Notes}
\begin{itemize}[leftmargin=*]
\item Mention any non-obvious implementation detail that is easy to get wrong.
\item Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
\end{itemize}
\end{document}
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}