Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions final/bitryssland/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
\problemname{Bitrussia}
\illustration{0.3}{coins.jpg}{Picture by \href{https://commons.wikimedia.org/wiki/File:Assorted_United_States_coins.jpg}{Elembis} (public domain)}
In the Republic of Bitrussia, a new coin system has recently been introduced.
There are $N$ different coin denominations worth $2^0, 2^1, 2^2, ..., 2^{N-1}$.

The small town of Napsaks is known for being full of interesting shops.
At the same time, Napsaks is notorious for never having any change in the shops.
You are also not allowed to pay more than the price.
It is therefore very important to bring plenty of coins of suitable denominations to be able to buy everything you want.

In Napsaks lives Darja-Pavla.
She is planning to go Christmas shopping and has brought $a_i$ coins of value $2^i$ ($i = 0, 1, ..., N-1$).
She will visit $M$ different shops and buy one thing in each shop.
The item she buys in shop $i$ costs $b_i$ ($i = 0, 1, ..., M-1$).
She is of course worried that her coins will not be enough to pay for everything she wants to buy. Help her determine this!

\section*{Input}
The first line contains two integers $1 \le N \le 50$ and $1 \le M \le 100\,000$, separated by spaces.
The next line contains the $N$ space-separated integers $0 \le a_0, a_1, ..., a_{N-1} \le 10^{15}$.
The third and last line contains the $M$ space-separated integers $0 \le b_0, b_1, ..., b_{M-1} \le 10^{15}$.

\section*{Output}
Output \texttt{ja} if Darja-Pavla can pay for everything she wants to buy with her coins.
Otherwise, output \texttt{nej}.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 19 & $M = 1, a_i \le 1$ \\ \hline
2 & 46 & $M = 1$ \\ \hline
3 & 35 & No additional constraints. \\ \hline
\end{tabular}

\section*{Explanation of Sample 1}
In the sample, Darja-Pavla has one coin worth $1$, three coins worth $2$, and one coin worth $4$.
She can pay for the item costing $5$ by using one coin worth $1$ and one coin worth $4$ ($1 + 4 = 5$).
She can then pay for the item costing $6$ with the three remaining coins of value $2$ ($2 + 2 + 2 = 6$).

\section*{Explanation of Sample 2}
In the sample, both items require that a coin of denomination $1$ is used, but she only has one coin of this denomination.
37 changes: 37 additions & 0 deletions final/julklappskop/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
\problemname{Christmas Shopping}
\illustration{0.3}{christmastree.jpg}{Picture by \href{https://commons.wikimedia.org/wiki/File:Christmas_presents_and_a_tree.jpg}{Trogain} (cc-by-sa4.0)}
Kind Allnäs is going to buy \emph{one Christmas present each} for her $K$ friends (even though it is February --- Allnäs believes in having a good margin).
The store she is in has \emph{exactly one} copy of each item.
There are $N$ items in total.
Allnäs knows her friends very well --- she knows exactly who likes what and how much.
She has written down a list of all $a_{ij}$ values, the numbers describing how much friend $i$ likes present $j$.

Now Allnäs wants to maximize her friends' happiness.
She wants to give her friends presents in such a way that the sum of happiness for each friend (i.e.\ the values $a_{ij}$) is maximized.
Which Christmas presents should she buy to maximize the sum of her friends' happiness?

\section*{Input}
The first line contains two integers $K$ (number of friends) and $N$ (number of presents).

The following $K$ lines contain $N$ integers each.
On the $i$th line, the $j$th integer is $0 \le a_{ij} \le 10^8$ --- how happy the $i$th friend becomes if they receive the $j$th present.

\section*{Output}
You shall output one integer --- the maximum sum of the friends' happiness.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 8 & $K = 2, 1 \le N \le 5000$ \\ \hline
2 & 15 & $K = 2, 1 \le N \le 100\,000$ \\ \hline
3 & 30 & $1 \le K \le 8, 1 \le N \le 100\,000$ \\ \hline
4 & 27 & $1 \le K \le 14, 1 \le N \le 200$ \\ \hline
5 & 20 & $1 \le K \le 14, 1 \le N \le 100\,000$ \\ \hline
\end{tabular}

\section*{Explanation of Sample 1}
If Allnäs buys present 3 for friend 1 and present 2 for friend 2, the sum is $a_{31} + a_{22} = 4 + 7 = 11$, which is the best possible.
57 changes: 57 additions & 0 deletions final/kubiskaboxar/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
\problemname{Cubic Boxes}
Your second cousin Paulo R loves boxes.
Right now you are on your way to celebrate Christmas with Paulo (traditionally you celebrate Christmas once with each part of your family, which currently consists of 72 different families).
Unfortunately, you have just realized that you forgot to buy Christmas presents!

Since Paulo loves boxes, that is exactly what you plan to buy for him.
A box is cubic with a certain side length, and has one of three colors --- red (R), green (G), or blue (B).
You have written a shopping list with all the boxes you plan to buy.
Unfortunately, the boxes are sold in three different stores, where each store sells boxes of a certain color.

Your plan is now to visit all three stores to buy the necessary boxes.
To save space in the luggage compartment, you plan to place some of the boxes inside each other.
If you visit the stores in the order $f_1, f_2, f_3$ (e.g.\ R, G, B), you may place boxes of color $f_3$ inside boxes of color $f_2$, and boxes of color $f_2$ inside boxes of color $f_1$.
The order R, G, B thus means you can place blue boxes inside green boxes, and green boxes inside red boxes.
You may \textbf{not} place boxes of color $f_3$ inside boxes of color $f_1$ --- that would be completely absurd.
Furthermore, a box can only be placed inside a box with a \textbf{strictly larger} side length.

\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{sample3}
\caption{A possible solution to sample 3.
On the left, a green box is placed inside a red box which is placed inside a blue box.
On the right, a green box is placed inside a red box.}
\label{fig:sample3}
\end{figure}

Can you determine in what order to visit the stores to minimize the number of \emph{outer boxes} (i.e.\ boxes that are not inside another box), if you place the boxes optimally?

\section*{Input}
The input starts with the number $N$, the number of boxes, where $1\le N \le 1\,000$. Then follow $N$ lines with side length
$l_i$ ($1 \le l_i \le 10\,000\,000$) and color $f_i$ (R, G, or B) for each box.

\section*{Output}
You shall output two lines.
The first line shall contain the order you visit the stores in, in the form $f_1\text{ }f_2\text{ }f_3$.
The second line shall consist of one integer --- the minimum number of outer boxes you can achieve after placing boxes inside each other.

If multiple orders give the same minimum number of outer boxes, you may output any of these orders.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 50 & You will always visit the stores in the order \texttt{B G R} \\ \hline
2 & 50 & No additional constraints. \\ \hline
\end{tabular}

\section*{Explanation of Sample 3}
A possible solution is illustrated in Figure~\ref{fig:sample3}.
The optimal order is to visit the stores in the order blue, red, green.

We can then place the two G boxes (size 1) inside one R box (size 10) each.
After that, one of the R boxes can be placed inside a B box.
This leaves one R box and one B box as outer boxes.
62 changes: 62 additions & 0 deletions final/snobollskrig1/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
\problemname{Snowball Fight 1}
\illustration{0.3}{snowballs.jpg}{Picture by \href{https://commons.wikimedia.org/wiki/File:Large_snowball_fight_near_Khaju_bridge.jpg}{Manfy} (cc-by-sa3.0)}
In an \href{https://en.wikipedia.org/wiki/Graph_(discrete_mathematics)}{undirected, weighted graph}
with $N$ nodes, $L$ countries are having a snowball fight during IOI.
In the beginning, each country has a fort at some node.

At time $0$, each country starts heading out for the snowball fight. The snowball fight works as follows:

\begin{itemize}
\item If a country owns a fort, the contestants from that country head out along all edges from the fort, all at the same speed.
\item If two countries meet along an edge, the countries stop and fight (forever).
\item If two countries meet at a node, the countries stop and fight (forever).
\item If a country reaches a node where countries are already fighting, it joins the fight.
\item If a country reaches a node before any other country, that country builds a fort at the node, and then heads out along the edges from the node according to rule 1.
\end{itemize}

Note that the rules imply that at most one country can have a fort at a given node.
If two countries arrive at a node at the same time, the contestants who arrived at the node will stay there and fight forever, without heading further.

Determine which pairs of countries will fight each other.

\section*{Input}

The first line contains three integers $N,L,M$ ($2 \le N \le 100\,000, 2 \le L \le 50, 1 \le M \le 100\,000$):
the number of nodes, countries, and edges in the graph, respectively.
Then follow $L$ lines with integers, specifying which node each country's starting base is at.
Finally follow $M$ lines with three integers each $a, b, w$ ($0 \le a,b < N, a \neq b, 1 \le w \le 2\,000$).
This means there is an (undirected) edge between nodes $a$ and $b$ (zero-indexed), of length $w$.

There will be at most one edge between each pair of nodes, and no two countries will start at the same node.

\section*{Output}

For each pair of countries $a, b$ that fight, output a line \texttt{a b}, where $a < b$ and the countries are indexed from 0.
These shall be output in sorted order, sorted by the first index first.
If for example $L = 3$ and all three countries fight, you shall output:
\begin{lstlisting}
0 1
0 2
1 2
\end{lstlisting}

\section*{Explanation of Sample 1}

In this example, the graph is a cycle and almost entirely symmetric. In the case between
country 0 and country 3, the fight will take place on an edge, while the other 3 fights
will take place at nodes.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 8 & The graph is a line: the edges are exactly (0,1), (1,2), etc., (N-2, N-1) \\ \hline
2 & 9 & $L = 2$. \\ \hline
3 & 24 & $w = 1$ for all edges. \\ \hline
4 & 23 & No fights occur at nodes. \\ \hline
5 & 29 & $1 \le N, M \le 2\,000$. \\ \hline
6 & 7 & No additional constraints. \\ \hline
\end{tabular}
56 changes: 56 additions & 0 deletions final/snomurskontrollant/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
\problemname{Snow Wall Inspector}
The PO jury cannot program. After the fiasco in the online qualification, where the broken judge for the problem \href{https://pokval16.kattis.com/problems/pokval16.snomur}{Snow Wall} accidentally gave Iceland the win with 211.58 out of 100 points on the problem, the jury has decided to outsource its judges to people who can actually code --- PO finalists.

The problem was as follows:

Sweden is building a snow wall of a certain width $W$.
As building material, there are a number of snow blocks that all have height 1, but can have different widths.
When the wall is constructed, each block must satisfy the following rule: on the row below the block,
at the two positions where the block has its endpoints, there must be a block immediately to the right and left of the point,
except at the beginning and end of a row, where there must instead be an endpoint \emph{on every row} (see the left, second-from-top wall in Figure~\ref{fig:sample} where this is missing on the top row).

Furthermore, there must not be a gap at the same position on two directly consecutive rows \emph{in the wall} (the empty row
just above the wall does not count).

The following image illustrates some invalid (left) and valid (right) walls:

\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{mur.png}
\caption{A number of invalid (left) and valid (right) walls.}
\label{fig:sample}
\end{figure}

Given a proposal for how the wall should look, determine whether the wall is a valid wall.

\section*{Input}
The first line contains two integers $W$ and $H$ --- the width and height of the wall.

The following $H$ lines describe the rows of the wall.
Each line starts with an integer $B \ge 1$, the number of blocks on the row.
This is followed by $B$ pairs of integers $P_j, L_j$, the (zero-indexed) position and length of the $j$th block on the row. These will be given in increasing $P_j$ order, i.e.\ from left to right.
No blocks will overlap or extend outside the wall.

The rows are given from the bottom up --- i.e.\ the first row in the input is the bottom row of the wall.

Let the sum of the number of blocks over all rows be $N$.
This value has limits in the scoring table.

\section*{Output}
You shall output \texttt{YES} if the wall is valid, and \texttt{NO} if it is not.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l | l |}
\hline
Group & Points & Constraints & Other \\ \hline
1 & 31 & $1 \le N, W, H \le 100\,000$ & No gap occurs directly above another gap \\ \hline
2 & 34 & $1 \le N, W, H \le 1\,000$ & \\ \hline
3 & 35 & $1 \le N, W, H \le 100\,000$ & \\ \hline
\end{tabular}

\section*{Explanation of Samples}
The first four samples correspond to the four invalid walls on the left in the image.
The last four samples correspond to the four valid walls on the right in the image.
41 changes: 41 additions & 0 deletions katt/brobygge/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
\def\version{1}
\problemname{Bridge Building}
In the island nation of Graf Kantaria, there are $N$ islands connected by $N - 1$ bridges, in such a way that it is possible to travel between every pair of islands using these bridges.

President Vick T. Adgraf and her husband Rick T. Adgraf have realized there are problems with this infrastructure setup.
The bridges were built because it was cheap, not because it would be fast to travel between the islands.
To increase their approval ratings, Vick and Rick want to build one extra bridge each in the nation.
They have written down some proposals for new bridges to build, and want to compare how the extra bridges change the distances between certain pairs of islands.

Your task is to write a program that, given all current bridges in the island nation and a list of either zero, one, or two extra bridges, can answer what the shortest distance between two islands becomes if the extra bridges are built.

\section*{Input}
The first line contains the integer $2 \le N \le 10^5$.
Then follow $N - 1$ lines, one for each of the current bridges.
The $i$th line contains the integers $0 \le A[i] \not= B[i] < N$ and $1 \le L[i] \le 1000$.
$A[i]$ and $B[i]$ give the islands that are the endpoints of the $i$th bridge, which has length $L[i]$.

The next line contains the integer $0 \le E \le 2$, the number of extra bridges your program should take into account.
The following $E$ lines contain the description of a bridge, in the same format as the original bridges.
None of the extra bridges coincide with the original bridges, or with each other.

The next line contains $0 \le Q \le 10^5$, the number of pairs of islands you need to find the shortest distance between.
Then follow $Q$ lines.
The $i$th of these contains the two distinct integers $F[i]$ and $T[i]$.

\section*{Output}
You shall output $Q$ lines.
The $i$th of these shall contain the shortest distance between islands $F[i]$ and $T[i]$.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 25 & The original bridges connect islands 0 and 1, 1 and 2, $\dots$, $n - 2$ and $n - 1$\\ \hline
2 & 25 & $E = 0$ \\ \hline
3 & 25 & $E = 1$ \\ \hline
4 & 25 & $E = 2$ \\ \hline
\end{tabular}
50 changes: 50 additions & 0 deletions katt/hemkor/problem_statement/problem.en.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
\def\version{1}
\problemname{Home Delivery}
Carl has just moved away from home, and has realized that he now needs to buy food himself.
Since it is tiresome to go to the store, he instead orders the food online from the website \emph{Hemkör}, which delivers groceries directly to his door.

Carl is now buying food for the coming centuries.
In total, Carl has planned to eat $1 \le N \le 5\,000$ meals (numbered from $1$ to $N$) during the next $100\,000$ days.
Carl plans to eat the $i$th meal $1 \le P[i] \le 100\,000$ days from today, and it requires a total of $1 \le Q[i] \le 100$ kilograms of food.
Carl is not picky --- as long as he has $Q[i]$ kilograms of ingredients, it does not matter which ingredients he uses.

On Hemkör, there are $1 \le M \le 100\,000$ different grocery items for sale.
The $i$th item has a weight of $1 \le V[i] \le 100$ kilograms, a cost of $1 \le K[i] \le 2\,000$ kronor, and an expiration date that is $1 \le D[i] \le 100\,000$ days from today (an item can be used up \emph{to and including} the day it expires).
Carl can buy as many copies of each grocery item as he wants.

Carl has determined that it is possible to buy groceries so that he can prepare all meals.
Can you help him order groceries in a way that is also as cheap as possible?

\section*{Example}
Suppose Carl plans to prepare $2$ meals on days $1$ and $10$, with weights $4$ kilograms and $1$ kilogram.
There are three grocery items, with weights $4$, $2$, and $4$ kilograms, costs $10$, $2$, and $3$, and expiration dates $10$, $5$, $5$.
Carl can buy one copy of the first item and one copy of the second item.
For the first meal, he can use $2$ kilograms of each item.
For the second meal, he uses $1$ kilogram of the first item, which expires on the same day the meal is prepared.
One kilogram of the first item is left over and not used.

In total, this costs $10 + 2 = 12$ kronor.

\section*{Input}
The first line contains the positive integers $N$ and $M$.
Then follow $N$ lines, one for each meal.
The $i$th line contains the integers $P[i]$ and $Q[i]$.

Then follow $M$ lines, one for each item.
The $i$th line contains the integers $V[i]$, $K[i]$, and $D[i]$.

\section*{Output}
Output one number --- the minimum cost to buy food for all meals.

\section*{Scoring}
Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

\noindent
\begin{tabular}{| l | l | l |}
\hline
Group & Points & Constraints \\ \hline
1 & 31 & $N \le 100, M \le 100$ \\ \hline
2 & 19 & $P[i] = 1$ for all meals \\ \hline
3 & 15 & $V[i] = 1$ for all items \\ \hline
4 & 35 & No additional constraints. \\ \hline
\end{tabular}
Loading