id
int64
0
402
problem_id
stringlengths
19
67
competition
stringclasses
14 values
contest
stringclasses
20 values
task_name
stringlengths
2
40
problem_statement
stringlengths
1.12k
16k
time_limit
float64
0.1
10
memory_limit
float64
256
2.05k
task_type
stringclasses
2 values
difficulty
int64
1
29
algorithms
stringlengths
10
133
setup_script
stringclasses
6 values
evaluation_script
stringclasses
6 values
grader_code
stringclasses
39 values
starter_code
stringclasses
39 values
0
IOI-2023-contest-beechtree
IOI
contest
beechtree
# Beech Tree Vétyem Woods is a famous woodland with lots of colorful trees. One of the oldest and tallest beech trees is called Ős Vezér. The tree Ős Vezér can be modeled as a set of $N$ **nodes** and $N-1$ **edges**. Nodes are numbered from $0$ to $N-1$ and edges are numbered from $1$ to $N-1$. Each edge connects tw...
1.5
2,048
batch
25
["greedy", "data structures", "tree map", "small to large", "binary search"]
{"grader.cpp": "#include \"beechtree.h\"\n#include <cassert>\n#include <cstdio>\n// BEGIN SECRET\n#include <string>\n// END SECRET\n\nint main()\n{\n // BEGIN SECRET\n const std::string input_secret = \"j2DRV0nYbs0y1xUYUGaiqtOKUU9vM9zi\";\n const std::string output_secret = \"p89vHUOQJ7iyHtdrgGXzKx8iRtXLL6wH\"...
{"beechtree.cpp": "#include \"beechtree.h\"\n\nstd::vector<int> beechtree(int N, int M, std::vector<int> P, std::vector<int> C)\n{\n return {};\n}\n", "grader.cpp": "#include \"beechtree.h\"\n#include <cassert>\n#include <cstdio>\n\nint main()\n{\n int N, M;\n assert(2 == scanf(\"%d %d\", &N, &M));\n std::v...
1
IOI-2023-contest-closing
IOI
contest
closing
# Closing Time Hungary is a country with $N$ cities, numbered from $0$ to $N - 1$. The cities are connected by $N - 1$ *bidirectional* roads, numbered from $0$ to $N - 2$. For each $j$ such that $0 \le j \le N - 2$, road $j$ connects city $U[j]$ and city $V[j]$ and has length $W[j]$, that is, it allows one to travel ...
1
2,048
batch
25
["greedy", "tree"]
{"grader.cpp": "#include \"closing.h\"\n\n#include <cassert>\n#include <cstdio>\n\n// BEGIN SECRET\n#include <string>\n// END SECRET\n#include <vector>\n\nint main()\n{\n // BEGIN SECRET\n {\n std::string in_secret = \"cc61ad56a4797fb3f5c9529f73ce6fcedd85669b\";\n std::string out_secret = \"081ce3c3...
{"grader.cpp": "#include \"closing.h\"\n\n#include <cassert>\n#include <cstdio>\n\n#include <vector>\n\nint main()\n{\n\n int Q;\n assert(1 == scanf(\"%d\", &Q));\n\n std::vector<int> N(Q), X(Q), Y(Q);\n std::vector<long long> K(Q);\n std::vector<std::vector<int>> U(Q), V(Q), W(Q);\n\n for (int q = 0;...
2
IOI-2023-contest-longesttrip
IOI
contest
longesttrip
# Longest Trip The IOI 2023 organizers are in big trouble! They forgot to plan the trip to Ópusztaszer for the upcoming day. But maybe it is not yet too late ... There are $N$ landmarks at Ópusztaszer indexed from $0$ to $N-1$. Some pairs of these landmarks are connected by *bidirectional* **roads**. Each pair of l...
1
2,048
interactive
25
["ad-hoc", "graph theory", "binary search"]
#!/bin/bash set -e # Exit immediately if a command fails # --- Fixed Files (Problem Specific) --- STUB_CPP="stub.cpp" MANAGER_CPP="manager.cpp" HEADER="longesttrip.h" TESTLIB_HEADER="testlib.h" # Needed for manager compilation # --- Argument Parsing --- # Expect exactly one argument: solution_file if [ "$#" -ne 1 ]; ...
#!/bin/bash set -e # Exit immediately if a command fails # --- Argument Parsing --- # Expect exactly two arguments: solution_file and input_file if [ "$#" -ne 2 ]; then echo "Usage: $0 <path/to/solution.cpp> <path/to/input.txt>" >&2 exit 1 fi SOLUTION_CPP="$1" # Get solution file from first argument INPUT_TXT=...
{"grader.cpp": "#include \"longesttrip.h\"\n\n#include <cassert>\n#include <cstdio>\n#include <string>\n#include <vector>\n\nstatic inline constexpr int maxNumberOfCalls = 32640;\nstatic inline constexpr int maxTotalNumberOfCalls = 150000;\nstatic inline constexpr int maxTotalNumberOfLandmarksInCalls = 1500000;\nstatic...
{"longesttrip.cpp": "#include \"longesttrip.h\"\n\nstd::vector<int> longest_trip(int N, int D)\n{\n return {};\n}\n", "grader.cpp": "#include \"longesttrip.h\"\n\n#include <cassert>\n#include <cstdio>\n#include <string>\n#include <vector>\n\nstatic inline constexpr int maxNumberOfCalls = 32640;\nstatic inline conste...
3
IOI-2023-contest-overtaking
IOI
contest
overtaking
# Overtaking There is a one-lane, one-way road from Budapest Airport to Hotel Forrás. The road is $L$ kilometres long. Over the IOI 2023 event, $N+1$ transfer buses traverse this road. Buses are numbered from $0$ to $N$. Bus $i$ ($0 \le i \lt N$) is scheduled to leave the airport at the $T[i]$-th second of the event,...
2.5
2,048
batch
23
["data structures", "tree map"]
{"grader.cpp": "#include \"overtaking.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n// BEGIN SECRET\n#include <string>\n// END SECRET\n\nint main()\n{\n // BEGIN SECRET\n const std::string input_secret = \"XwWPuInrOjpekAwGKojzwKw3yVDtdkGS\";\n const std::string output_secret = \"mGlgT4yvr1qPbq...
{"grader.cpp": "#include \"overtaking.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n\nint main()\n{\n int L, N, X, M, Q;\n assert(5 == scanf(\"%d %d %d %d %d\", &L, &N, &X, &M, &Q));\n std::vector<long long> T(N);\n for (int i = 0; i < N; i++)\n assert(1 == scanf(\"%lld\", &T[i]));\n...
4
IOI-2023-contest-robot
IOI
contest
robot
# Robot Contest AI researchers at the University of Szeged are holding a robot programming contest. Your friend, Hanga, has decided to take part in the contest. The objective is to program the ultimate _Pulibot_, admiring the great intelligence of the famous Hungarian herding dog breed, the Puli. Pulibot will be test...
1
2,048
interactive
28
["bfs", "graph theory", "constructive", "ad-hoc", "tree", "implementation", "graph traversal"]
#!/bin/bash set -e # Exit immediately if a command fails echo "--- Setup Script (Robot Problem) ---" # --- Fixed Files (Problem Specific) --- STUB_CPP="stub.cpp" # Stub for the robot problem MANAGER_CPP="manager.cpp" # Manager for the robot problem HEADER="robot.h" # Header for the robot pro...
#!/bin/bash set -e # Exit immediately if a command fails echo "--- Evaluation Script (Robot Problem) ---" # --- Argument Parsing --- # Expect exactly two arguments: solution_file and input_file if [ "$#" -ne 2 ]; then echo "Usage: $0 <path/to/solution.cpp> <path/to/input.txt>" >&2 echo "Note: Run setup_robot....
{"grader.cpp": "#include \"robot.h\"\n#include <cassert>\n#include <string>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <iomanip>\n\nstatic const int MAX_COLOR = 19;\nstatic const int MAX_STATE = 5153632; // = (MAX_COLOR + 3) ^ 5\nstatic const int MAX_STEPS = 500000;\n\nstatic std::ofstream o...
{"grader.cpp": "#include \"robot.h\"\n#include <cassert>\n#include <string>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <iomanip>\n\nstatic const int MAX_COLOR = 19;\nstatic const int MAX_STATE = 5153632; // = (MAX_COLOR + 3) ^ 5\nstatic const int MAX_STEPS = 500000;\n\nstatic std::ofstream o...
5
IOI-2023-contest-soccer
IOI
contest
soccer
# Soccer Stadium Nagyerdő is a square-shaped forest located in the city of Debrecen, which can be modeled as an $N \times N$ grid of cells. The rows of the grid are numbered from $0$ to $N - 1$ from north to south, and the columns are numbered from $0$ to $N - 1$ from west to east. We refer to the cell located at ro...
3.5
2,048
batch
26
["dynamic programming", "tree", "cartesian tree", "prefix sum", "binary search"]
{"grader.cpp": "#include \"soccer.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n// BEGIN SECRET\n#include <string>\n// END SECRET\n\nint main()\n{\n // BEGIN SECRET\n const std::string input_secret = \"R0R7sb2atQWJ6SAWOjw4ZG7Gwgo5zl9L\";\n const std::string output_secret = \"xlqtkQVzqzbOJxjzxl...
{"grader.cpp": "#include \"soccer.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n\nint main()\n{\n int N;\n assert(1 == scanf(\"%d\", &N));\n std::vector<std::vector<int>> F(N, std::vector<int>(N));\n for (int i = 0; i < N; i++)\n {\n for (int j = 0; j < N; j++)\n {\n ...
6
IOI-2024-contest-hieroglyphs
IOI
contest
hieroglyphs
# Hieroglyphs A team of researchers is studying the similarities between sequences of hieroglyphs. They represent each hieroglyph with a non-negative integer. To perform their study, they use the following concepts about sequences. For a fixed sequence $A$, a sequence $S$ is called a **subsequence** of $A$ if and ...
1
2,048
batch
28
["greedy", "dynamic programming", "ad-hoc", "data structures", "segment tree"]
{"grader.cpp": "#include \"hieroglyphs.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n// BEGIN SECRET\n#include <cstdlib>\n#include <string>\n\nnamespace {\n\nvoid write_grader_result(std::string grader_result, std::string grader_msg = \"\") {\n const std::string output_secret = \"IyRwUZ9rsuq5tjuK54lpS...
{"grader.cpp": "#include \"hieroglyphs.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n\nint main() {\n int N, M;\n assert(2 == scanf(\"%d%d\", &N, &M));\n std::vector<int> A(N), B(M);\n for (int i = 0; i < N; i++)\n assert(1 == scanf(\"%d\", &A[i]));\n for (int j = 0; j < M; j++)\n assert(1 =...
7
IOI-2024-contest-message
IOI
contest
message
# Message Aisha and Basma are two friends who correspond with each other. Aisha has a message $M$, which is a sequence of $S$ bits (i.e., zeroes or ones), that she would like to send to Basma. Aisha communicates with Basma by sending her **packets**. A packet is a sequence of $31$ bits indexed from $0$ to $30$. Aisha...
3
2,048
interactive
28
["graph theory", "ad-hoc", "constructive", "functional graph"]
#!/bin/bash set -e # Exit immediately if a command fails # --- Fixed Files (Problem Specific) --- STUB_CPP="stub.cpp" # Stub for message problem MANAGER_CPP="manager.cpp" # Manager for message problem HEADER="message.h" # Header for message problem # TESTLIB_HEADER="testlib.h" # Assumed present, ...
#!/bin/bash set -e # Exit immediately if a command fails echo "--- Evaluation Script ---" # --- Argument Parsing --- # Expect exactly two arguments: solution_file and input_file if [ "$#" -ne 2 ]; then echo "Usage: $0 <path/to/solution.cpp> <path/to/input.txt>" >&2 echo "Note: Run setup.sh <path/to/solution.c...
{"grader.cpp": "#include \"message.h\"\n#include <cassert>\n#include <cstdio>\n#include <cstdlib>\n\nnamespace {\nconst int PACKET_SIZE = 31;\nconst int CALLS_CNT_LIMIT = 100;\n\nint calls_cnt;\nstd::vector<bool> C(PACKET_SIZE);\nstd::vector<std::vector<bool>> R;\n\nvoid quit(const char* message) {\n printf(\"%s\\n\",...
{"message.cpp": "#include \"message.h\"\n\nvoid send_message(std::vector<bool> M, std::vector<bool> C) {\n std::vector<bool> A(31, 0);\n send_packet(A);\n}\n\nstd::vector<bool> receive_message(std::vector<std::vector<bool>> R) {\n return std::vector<bool>({0, 1, 1, 0});\n}\n", "grader.cpp": "#include \"message.h\"\n...
8
IOI-2024-contest-mosaic
IOI
contest
mosaic
# Mosaic Salma plans to colour a clay mosaic on a wall. The mosaic is an $N \times N$ grid, made of $N^2$ initially uncoloured $1 \times 1$ square tiles. The rows of the mosaic are numbered from $0$ to $N-1$ from top to bottom, and the columns are numbered from $0$ to $N-1$ from left to right. The tile in row $i$ an...
1
2,048
batch
20
["implementation", "ad-hoc", "prefix sum"]
{"grader.cpp": "#include \"mosaic.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n// BEGIN SECRET\n#include <cstdlib>\n#include <string>\n\nnamespace {\n\nvoid write_grader_result(std::string grader_result, std::string grader_msg = \"\") {\n const std::string output_secret = \"Wm5rkGNobnYjFI7TIY17RAm6FA...
{"grader.cpp": "#include \"mosaic.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n\nint main() {\n int N;\n assert(1 == scanf(\"%d\", &N));\n std::vector<int> X(N), Y(N);\n for (int i = 0; i < N; i++)\n assert(1 == scanf(\"%d\", &X[i]));\n for (int i = 0; i < N; i++)\n assert(1 == scanf(\"%d\"...
9
IOI-2024-contest-nile
IOI
contest
nile
# Nile You want to transport $N$ artifacts through the Nile. The artifacts are numbered from $0$ to $N-1$. The weight of artifact $i$ ($0 \leq i < N$) is $W[i]$. To transport the artifacts, you use specialized boats. Each boat can carry **at most two** artifacts. * If you decide to put a single artifact in a boat, ...
2
2,048
batch
20
["data structure", "segment tree", "disjoint set", "offline queries"]
{"grader.cpp": "#include \"nile.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n// BEGIN SECRET\n#include <cstdlib>\n#include <string>\n\nnamespace {\n\nvoid write_grader_result(std::string grader_result, std::string grader_msg = \"\") {\n const std::string output_secret = \"4FBwMMwcdlgPodEtp0owUlxQgA5S...
{"grader.cpp": "#include \"nile.h\"\n#include <cassert>\n#include <cstdio>\n#include <vector>\n\nint main() {\n int N;\n assert(1 == scanf(\"%d\", &N));\n std::vector<int> W(N), A(N), B(N);\n for (int i = 0; i < N; i++)\n assert(3 == scanf(\"%d%d%d\", &W[i], &A[i], &B[i]));\n int Q;\n assert(1 == scanf(\"%d\",...
10
IOI-2024-contest-sphinx
IOI
contest
sphinx
# Sphinx's Riddle The Great Sphinx has a riddle for you. You are given a graph on $N$ vertices. The vertices are numbered from $0$ to $N - 1$. There are $M$ edges in the graph, numbered from $0$ to $M-1$. Each edge connects a pair of distinct vertices and is bidirectional. Specifically, for each $j$ from $0$ to $M - ...
1.5
2,048
interactive
24
["graph theory", "union-find", "data structures", "binary search", "implementation", "constructive"]
#!/bin/bash set -e # Exit immediately if a command fails echo "--- Setup Script (Sphinx Problem) ---" # --- Fixed Files (Problem Specific) --- STUB_CPP="stub.cpp" # Stub for sphinx problem MANAGER_CPP="manager.cpp" # Manager for sphinx problem HEADER="sphinx.h" # Header for sphinx problem TESTLIB_...
#!/bin/bash set -e # Exit immediately if a command fails echo "--- Evaluation Script (Sphinx Problem) ---" # --- Argument Parsing --- # Expect exactly two arguments: solution_file and input_file if [ "$#" -ne 2 ]; then echo "Usage: $0 <path/to/solution.cpp> <path/to/input.txt>" >&2 echo "Note: Run setup.sh <p...
{"grader.cpp": "#include \"sphinx.h\"\n#include <cassert>\n#include <cstdio>\n#include <queue>\n#include <string>\n#include <vector>\n\nnamespace {\n\nconst int CALLS_CNT_LIMIT = 2750;\n\nint calls_cnt;\n\nint N, M;\nstd::vector<int> C;\nstd::vector<int> X, Y;\nstd::vector<std::vector<int>> adj;\n\nvoid quit(const char...
{"grader.cpp": "#include \"sphinx.h\"\n#include <cassert>\n#include <cstdio>\n#include <queue>\n#include <string>\n#include <vector>\n\nnamespace {\n\nconst int CALLS_CNT_LIMIT = 2750;\n\nint calls_cnt;\n\nint N, M;\nstd::vector<int> C;\nstd::vector<int> X, Y;\nstd::vector<std::vector<int>> adj;\n\nvoid quit(const char...
11
IOI-2024-contest-tree
IOI
contest
tree
# Tree Consider a **tree** consisting of $N$ **vertices**, numbered from $0$ to $N-1$. Vertex $0$ is called the **root**. Every vertex, except for the root, has a single **parent**. For every $i$, such that $1 \leq i < N$, the parent of vertex $i$ is vertex $P[i]$, where $P[i] < i$. We also assume $P[0] = -1$. For ...
2
2,048
batch
25
["greedy", "union-find", "data structures", "small to large", "tree"]
{"grader.cpp": "#include \"tree.h\"\n#include <cassert>\n#include <cstdio>\n// BEGIN SECRET\n#include <cstdlib>\n#include <string>\n\nnamespace {\n\nvoid write_grader_result(std::string grader_result, std::string grader_msg = \"\") {\n const std::string output_secret = \"11XNDQnkdGXK8y3iaqfMvWKu4vqrBbz1\";\n printf(\...
{"grader.cpp": "#include \"tree.h\"\n#include <cassert>\n#include <cstdio>\n\nint main() {\n int N;\n assert(1 == scanf(\"%d\", &N));\n std::vector<int> P(N);\n P[0] = -1;\n for (int i = 1; i < N; i++)\n assert(1 == scanf(\"%d\", &P[i]));\n std::vector<int> W(N);\n for (int i = 0; i < N; i++)\n assert(1 ==...
12
BOI-2023-contest-astronomer
BOI
contest
astronomer
# Astronomer Problem ID: astronomer The astronomer has a passion for stargazing. In particular, he gets immense pleasure out of gazing at $k$ stars simultaneously through his telescope. Building a telescope with radius $r$ costs $t \cdot r$ kroner. A newly built telescope will point exactly at the origin $(0, 0)$. Mov...
5
1,024
batch
19
["geometry", "ternary search", "sorting", "optimization"]
13
BOI-2023-contest-minequake
BOI
contest
minequake
# Minequake Problem ID: minequake The fully autonomous microbreweries installed in the abandoned Dwarven mines of Moravia are truly a testament to the ingenuity and craftsmanship of Dwarven engineering! Alas, sometimes earthquakes rattle the mines, leading to misaligned pipes and funnels spilling precious liquid on th...
2
1,024
batch
24
["tree dp", "rerooting", "graph traversal", "dynamic programming"]
14
BOI-2023-contest-mineraldeposits
BOI
contest
mineraldeposits
# Mineral deposits Problem ID: mineraldeposits You handle signal processing for an extra-terrestrial mining company, and your vessel is currently approaching an asteroid. Preliminary scans show the presence of $k$ mineral deposits on the asteroid, but their precise locations are unknown. The surface of the asteroid c...
2
1,024
interactive
25
["set", "geometric transformation", "bipartite matching", "interactive"]
{"interactor.cpp": "// Adapted from boi2023_tests/mineraldeposits/output_validators/validate.py\n// Author: HeRaNO\n\n#include \"testlib.h\"\n\nconst int INF = 100'000'000;\n\nint main(int argc, char *argv[])\n{\n\tregisterInteraction(argc, argv);\n\tint b = inf.readInt();\n\tint k = inf.readInt();\n\tint w = inf.readI...
{"interactor.cpp": "// Adapted from boi2023_tests/mineraldeposits/output_validators/validate.py\n// Author: HeRaNO\n\n#include \"testlib.h\"\n\nconst int INF = 100'000'000;\n\nint main(int argc, char *argv[])\n{\n\tregisterInteraction(argc, argv);\n\tint b = inf.readInt();\n\tint k = inf.readInt();\n\tint w = inf.readI...
15
BOI-2023-contest-sequence
BOI
contest
sequence
## Sequence **Problem ID:** sequence A sequence of positive integers $(x_1, ..., x_m)$ is *good* if $x_1 = 1$ and for each $1 < j \le m$ we have either $x_j = x_{j-1} + 1$ or $x_j = x_k \cdot x_l$ for some $k$ and $l$ with $0 < k \le l < j$. For instance, the sequences $(1, 1)$ and $(1, 2)$ are both good, but the sequ...
1
1,024
batch
24
["shortest path", "number theory", "dynamic programming"]
16
BOI-2023-contest-staringcontest
BOI
contest
staringcontest
# Staring Contest Problem ID: staringcontest A staring contest is a classical battle of imperturbability in which two people stare into each other's eyes while maintaining a facial expression of assured serenity. The goal is to maintain eye contact for longer than your opponent. The contest ends when one participant b...
1
1,024
interactive
18
["randomized algorithms"]
{"interactor.cpp": "// Adapted from boi2023_tests/staringcontest/output_validators/validate.py\n// Author: HeRaNO\n\n#include \"testlib.h\"\n\nint main(int argc, char *argv[])\n{\n\tregisterInteraction(argc, argv);\n\tstd::vector<int> skills;\n\twhile (!inf.seekEof())\n\t\tskills.push_back(inf.readInt());\n\tint n = sk...
{"interactor.cpp": "// Adapted from boi2023_tests/staringcontest/output_validators/validate.py\n// Author: HeRaNO\n\n#include \"testlib.h\"\n\nint main(int argc, char *argv[])\n{\n\tregisterInteraction(argc, argv);\n\tstd::vector<int> skills;\n\twhile (!inf.seekEof())\n\t\tskills.push_back(inf.readInt());\n\tint n = sk...
17
BOI-2023-contest-tycho
BOI
contest
tycho
# Tycho Problem ID: tycho The planetary exploration vehicle *Tycho VIII* needs to get back to the home base after collecting mineral samples. Tycho travels in a straight line from position 0 to the home base at position *b*. While moving, it advances at a slow but steady pace of 1 unit per second. Every second, Tycho ...
2
1,024
batch
22
["shortest path", "modular arithmetic", "dynamic programming"]
18
BOI-2024-contest-fire
BOI
contest
fire
# Fire ![](_page_0_Picture_0.jpeg) In the old Baltic religion, it is important to have a holy fire burning. A priest called *krivis* is responsible for protecting it from extinguishing. He has many trustworthy helpers called *vaidilutė*s, and wants to create a schedule for them to stoke and protect the fire. He has t...
1
256
batch
19
["sparse table", "data structures", "greedy", "coordinate compression"]
19
BOI-2024-contest-jobs
BOI
contest
jobs
![](_page_0_Picture_16.jpeg) # Jobs You have a successful business where you make money by completing jobs for your clients. Currently, you can choose from *N* one-time jobs, numbered from 1 to *N*. Completing job *i* will make you a profit of *x<sub>i</sub>* euros. The profit may also be negative (*x<sub>i</sub>* <...
1
256
batch
23
["greedy", "data structures", "small to large", "priority queue", "tree"]
20
BOI-2024-contest-portal
BOI
contest
portal
![](_page_0_Picture_11.jpeg) # Portal You think it would be funny to prank your best friend by placing them on cell (0, 0) of an infinite grid of coloured cells. The friend then moves around the grid indefinitely, one step at a time, always moving to one of the four adjacent cells. *N* of the cells on the grid conta...
1
256
batch
21
["number theory", "mathematics", "linear algebra", "euclidean algorithm", "extended euclidean"]
21
BOI-2024-contest-tiles
BOI
contest
tiles
# Tiles ![](_page_0_Picture_0.jpeg) Soon after converting to Christianity, it is believed that the first and the only Lithuanian King Mindaugas ordered the construction of the Vilnius Cathedral. The construction is almost completed, except that the floor has to be covered with ceramic ornamented glazed tiles. The fl...
1
256
batch
22
["line sweep", "data structures", "tree map"]
22
BOI-2024-contest-trains
BOI
contest
trains
![](_page_0_Picture_0.jpeg) # Trains You have arrived in Vilnius and want to visit various cities in Lithuania. Cities in Lithuania are located on a straight line and numbered from 1 to *N* sequentially. Vilnius is assigned the number 1. Each city has a train station with a single train route that operates from tha...
1
512
batch
19
["sqrt decomposition", "prefix sum", "dynamic programming"]
23
BOI-2024-contest-wall
BOI
contest
wall
![BOI 2024 Logo](_page_0_Picture_0.jpeg) # Flooding Wall It's the 14th century and construction of the Trakai Island Castle is to begin soon. The first task on the chief architect's list is to plan the construction of the main castle wall. Building a wall that can protect the castle from any possible attack is quite...
5
256
batch
23
["implementation", "data structures", "segment tree", "coordinate compression"]
24
BOI-2025-contest-boi
BOI
contest
boi
# Task: BOI Acronym ![BOI Logo](_page_0_Picture_1.jpeg) **BOI 2025, Day 1. Available memory: 256 MB.** *2025.04.26* As you certainly know, *BOI* is an acronym for the name of the *Baltic Olympiad in Informatics*. The organisers find the acronym *BOI* too easy to pronounce (it forms a single syllable in the English l...
1
256
batch
25
["dynamic programming", "string", "union-find"]
25
BOI-2025-contest-dev
BOI
contest
dev
# Task: DEV ## Developer [![BOI](_page_0_Picture_1.jpeg)](_page_0_Picture_1.jpeg) [![TORUŃ 2025](_page_0_Picture_2.jpeg)](_page_0_Picture_2.jpeg) 2025.04.27 You are in charge of developing new properties in the suburbs of Toruń. You have already decided that there will be one main street and *n* properties numbered ...
2
512
batch
26
["segment tree", "coordinate compression", "dynamic programming"]
26
BOI-2025-contest-exp
BOI
contest
exp
# Task: EXP Exponents BOI 2025, Day 2. Available memory: 1024 MB. ![](BOI) 2025.04.27 The famous polymath Nicolaus Copernicus was born and grew up in Toruń in the 15th century. Archaeologists have recently discovered his notebook, and learned that he was fond of using powers of two to store large numbers. In partic...
1
256
batch
25
["divide and conquer", "dynamic programming", "data structures", "range queries", "binary search"]
27
BOI-2025-contest-gcd
BOI
contest
gcd
# Task: GCD Gingerbread BOI 2025, Day 2. Available memory: 256 MB. ![](https://i.imgur.com/your_image.png) Toruń has been known for its traditional gingerbread since the Middle Ages. Young Nicolaus would like to buy a set of *n* boxes with gingerbread cookies in his favourite shop. The shop has very strict rules, th...
1
256
batch
18
["number theory", "search", "gcd"]
28
BOI-2025-contest-tou
BOI
contest
tou
# Task: TOU ## Tour ![](_page_0_Picture_1.jpeg) **BOI 2025, Day 1. Available memory: 1024 MB.** There are many tourist attractions in Toruń. Our tour guides prepared a list of *m* one-way walks connecting *n* meeting points in the city center. The walks are numbered from 1 to *m* and similarly the meeting points are...
2
1,024
batch
24
["graph modeling", "graph cycles", "graph traversal", "dfs"]
29
BOI-2025-contest-tow
BOI
contest
tow
# Task: TOW Tower ![](_page_0_Picture_1.jpeg) BOI 2025, Day 1. Available memory: 256 MB. 2025.04.26 There are many legends concerning the Leaning Tower of Toruń. The wall of the tower is a circle with *N* ≥ 3 evenly spaced doors (in other words, the doors are the vertices of a regular *N*-gon). The doors are number...
2
256
batch
24
["geometry", "search", "interactive", "graph traversal"]
{"interactor.cpp": "#include <bits/stdc++.h>\n\n#include \"testlib.h\"\n\nusing namespace std;\n\nconst long double PI = acosl(-1);\n\nlong double calculateDistance(int pos1, int pos2, int n) {\n long double angle1 = 2.0 * PI * pos1 / n;\n long double angle2 = 2.0 * PI * pos2 / n;\n\n long double angleDiff = f...
{"interactor.cpp": "#include <bits/stdc++.h>\n\n#include \"testlib.h\"\n\nusing namespace std;\n\nconst long double PI = acosl(-1);\n\nlong double calculateDistance(int pos1, int pos2, int n) {\n long double angle1 = 2.0 * PI * pos1 / n;\n long double angle2 = 2.0 * PI * pos2 / n;\n\n long double angleDiff = f...
30
CEOI-2023-contest-avoid
CEOI
contest
avoid
![](_page_0_Picture_0.jpeg) # How to Avoid Disqualification in 75 Easy Steps (avoid) You are standing in front of the open safe, a medal in your hand. But your triumph turns to despair as you look around: a message on a tie you found in the room reveals that your assistant exposed your plan to the Scientific Committe...
0.25
512
interactive
29
["binary search", "bitmask", "precomputation", "heuristics", "simulated annealing", "constructive"]
{"grader.cpp": "/*\nSAMPLE GRADER for task AVOID\n\nUSAGE:\nplace together with your solution and avoid.h in the same directory, then:\ng++ <flags> sample_grader.cpp <solution_file>\ne.g.:\ng++ -std=c++17 sample_grader.cpp avoid.cpp\n\nINPUT/OUTPUT:\nThe sample grader first expects on standard input the integers R and ...
{"grader.cpp": "/*\nSAMPLE GRADER for task AVOID\n\nUSAGE:\nplace together with your solution and avoid.h in the same directory, then:\ng++ <flags> sample_grader.cpp <solution_file>\ne.g.:\ng++ -std=c++17 sample_grader.cpp avoid.cpp\n\nINPUT/OUTPUT:\nThe sample grader first expects on standard input the integers R and ...
31
CEOI-2023-contest-balance
CEOI
contest
balance
![CEOI 2023](_page_0_Picture_0.jpeg) # Brought Down the Grading Server? (balance) A hectic first competition day has passed... While the Scientific Committee narrowly fought off the hacking attack on the grading server, they fear that it affected the scoring of the submissions. There is only one option: all submissio...
2
1,024
batch
21
["sorting", "bitmask", "constructive"]
32
CEOI-2023-contest-light
CEOI
contest
light
![](_page_0_Picture_0.jpeg) # A Light Inconvenience (light) The Scientific Committee is relaxing at the opening ceremony of this year's CEOI. The tasks are prepared, the grading server's 10<sup>12</sup> firewalls are finally up, and the committee is looking forward to an amazing show with flaming torches. Nothing can...
1
512
interactive
20
["ad-hoc"]
{"grader.cpp": "/*\nSAMPLE GRADER for task LIGHT\n\nUSAGE:\nplace together with your solution and light.h in the same directory, then:\ng++ <flags> sample_grader.cpp <solution_file>\ne.g.:\ng++ -std=c++17 sample_grader.cpp light.cpp\n\nINPUT/OUTPUT:\nThe sample grader first expects on standard input the integer Q. It t...
{"grader.cpp": "/*\nSAMPLE GRADER for task LIGHT\n\nUSAGE:\nplace together with your solution and light.h in the same directory, then:\ng++ <flags> sample_grader.cpp <solution_file>\ne.g.:\ng++ -std=c++17 sample_grader.cpp light.cpp\n\nINPUT/OUTPUT:\nThe sample grader first expects on standard input the integer Q. It t...
33
CEOI-2023-contest-trade
CEOI
contest
trade
![](_page_0_Picture_0.jpeg) # Tricks of the Trade (trade) Since your career as an art thief turned out to be decidedly less glamorous than you had hoped for, you have set your eyes on a new target: you want to steal a medal at this year's CEOI!* So far your evil plan is working as intended: The Scientific Committee, ...
7
2,048
batch
25
["greedy", "divide and conquer", "dynamic programming", "data structures", "line sweep", "segment tree"]
34
CEOI-2023-contest-grading-server
CEOI
contest
grading-server
![](_page_0_Picture_0.jpeg) # Bring Down the Sky Grading Server (grading-server) Despite running low on oil, the opening ceremony was a great success.* Now, the committee is looking forward to the first competition day. But what's this? The chairman of the Technical Committee noticed some suspicious network activity—...
4
1,024
batch
23
["eulerian path", "graph theory", "divide and conquer"]
35
CEOI-2024-contest-battle
CEOI
contest
battle
# Naval battle Ondra has recently been promoted to Grand admiral of the Czech Navy. However, when he finally started thinking he had a secure job, the government announced budget cuts including dissolution of the Navy. So Ondra decided to show the government how important the Czech Navy is. He knows from his spies ab...
3
1,024
batch
21
["data structures", "simulation", "tree map", "priority queue", "implementation", "linked list"]
36
CEOI-2024-contest-covid
CEOI
contest
covid
# COVID tests In Adam's school, there has been a new wave of the COVID epidemic. In order to prevent further spreading, the school has decided to test all the students using antigen tests with samples of the students' saliva. Since all teachers have forgotten how to use those a long time ago, Adam signed himself up a...
5
1,024
interactive
24
["optimization", "divide and conquer", "combinatorics", "probabilistic method"]
{"interactor.cpp": "// Author: Ji\u0159\u00ed Kalvoda\n#include <stdio.h>\n#include <bitset>\n#include <vector>\n#include <cassert>\n#include <cmath>\n#include <cstring>\n#include <signal.h>\n#include \"testlib.h\"\nusing namespace std;\n#define D if(0)\n\nconst int MAX_QUERIES_SUM = 5'000'000;\n\nusing ll = long long;...
{"interactor.cpp": "// Author: Ji\u0159\u00ed Kalvoda\n#include <stdio.h>\n#include <bitset>\n#include <vector>\n#include <cassert>\n#include <cmath>\n#include <cstring>\n#include <signal.h>\n#include \"testlib.h\"\nusing namespace std;\n#define D if(0)\n\nconst int MAX_QUERIES_SUM = 5'000'000;\n\nusing ll = long long;...
37
CEOI-2024-contest-editor
CEOI
contest
editor
# Text editor Robert is competing in CEOI 2024. He has almost finished his solution to the hardest problem of the day, and not just that, he's pretty sure it will get 100 points! There is just one small issue: He made a typo! What's worse, his favorite computer mouse, which he had been using since 2008, seems to have ...
4
1,024
batch
16
["graph theory", "dijkstra", "data structures", "shortest path", "stack"]
38
CEOI-2024-contest-sprinklers
CEOI
contest
sprinklers
# Sprinklers Václav has a beautiful flower garden consisting of $M$ flowers planted on a single line. On this line, Václav has also placed $N$ sprinklers to water his flowers. The positions of the sprinklers are given by the numbers $s_{1},\ldots,s_{N}$. The positions of the flowers are given by the numbers $f_{1},\l...
2
1,024
batch
22
["greedy", "dynamic programming", "data structures", "parametric search", "stack", "binary search"]
39
CEOI-2024-contest-stations
CEOI
contest
stations
# Petrol stations The Czech highway network consists of $N$ cities and $N-1$ roads with known lengths in kilometers. We know that there exists exactly one path between each pair of cities. Furthermore, there exists exactly one petrol station in each of the cities and nowhere else. One day, several people decided to g...
3.5
2,048
batch
24
["centroid decomposition", "divide and conquer", "tree", "implementation", "prefix sum", "binary search"]
40
CEOI-2024-contest-toy
CEOI
contest
toy
# Toy For creating a task for CEOI 2024, Ben was given a toy as a present from the scientific committee. The toy is a puzzle which can be imagined as a $H \times W$ grid containing a metal object consisting of two parts: A horizontal $1\times K$ part and a vertical $L \times 1$ part, which are loosely attached to each...
1.35
1,024
batch
17
["graph traversal", "bfs", "graph theory", "dynamic programming"]
41
CCO-2023-Canadian_Computing_Competition_Senior-s1j4
CCO
Canadian_Computing_Competition_Senior
s1j4
# Problem J4/S1: Trianglane ## Problem Description Bocchi the Builder just finished constructing her latest project: a laneway consisting of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck! She accidentally spilled black paint on some of the tiles. Now, some of the tiles a...
1
512
batch
7
["implementation", "geometry"]
42
CCO-2023-Canadian_Computing_Competition_Senior-s2
CCO
Canadian_Computing_Competition_Senior
s2
# Problem S2: Symmetric Mountains ## Problem Description Rebecca is a tour guide and is trying to market the Rocky Mountains for her magazine. She recently took a beautiful picture consisting of $N$ mountains where the $i$-th mountain from the left has a height $h_i$. She will crop this picture for her magazine, by p...
1
512
batch
12
["dynamic programming"]
43
CCO-2023-Canadian_Computing_Competition_Senior-s3
CCO
Canadian_Computing_Competition_Senior
s3
# Problem S3: Palindromic Poster ### Problem Description Ryo and Kita are designing a new poster for Kessoku Band. After some furious brainstorming, they came to the conclusion that the poster should come in the form of a 2-D grid of lowercase English letters (i.e. a to z), with $N$ rows and $M$ columns. Furthermore...
1
512
batch
16
["case analysis", "constructive"]
44
CCO-2023-Canadian_Computing_Competition_Senior-s4
CCO
Canadian_Computing_Competition_Senior
s4
## Problem S4: Minimum Cost Roads # Problem Description As the newly elected mayor of Kitchener, Alanna's first job is to improve the city's road plan. Kitchener's current road plan can be represented as a collection of $N$ intersections with $M$ roads, where the i-th road has length $l_i$ meters, costs $c_i$ dollar...
1.5
512
batch
18
["dijkstra", "shortest path", "graph theory", "spanning tree"]
45
CCO-2023-Canadian_Computing_Competition_Senior-s5
CCO
Canadian_Computing_Competition_Senior
s5
# Problem S5: The Filter ## Problem Description Alice, the mathematician, likes to study real numbers that are between 0 and 1. Her favourite tool is the filter. A filter covers part of the number line. When a number reaches a filter, two events can happen. If a number is not covered by the filter, the number will p...
1.5
512
batch
24
["set", "number theory", "graph theory", "mathematical optimization"]
46
CCO-2023-Canadian_Computing_Olympiad-d1p1
CCO
Canadian_Computing_Olympiad
d1p1
# 2023 Canadian Computing Olympiad # Day 1, Problem 1 # Binaria ### Time Limit: 1 second ## Problem Description You have been hired by the Cheap Communication Organization (CCO) to work on a communication breakthrough: sub-message sum (SMS). This revolutionary idea works as follows. Given a binary string of length ...
1
1,024
batch
17
["number theory", "ad-hoc", "mathematics", "combinatorics", "modular arithmetic"]
47
CCO-2023-Canadian_Computing_Olympiad-d1p2
CCO
Canadian_Computing_Olympiad
d1p2
# 2023 Canadian Computing Olympiad # Day 1, Problem 2 # Real Mountains **Time Limit:** 5 seconds ## Problem Description Thanks to your help with cropping her picture, Rebecca's scenic photo is now featured on the front cover of the newest issue of her magazine. However, it seems that some of her readers still aren't...
5
1,024
batch
22
["line sweep", "data structures", "segment tree"]
48
CCO-2023-Canadian_Computing_Olympiad-d1p3
CCO
Canadian_Computing_Olympiad
d1p3
# 2023 Canadian Computing Olympiad # Day 1, Problem 3 # Line Town **Time Limit:** 2 seconds **Problem Description** The $N$ residents of Line Town have arranged themselves in a line. Initially, the residents have happiness values of $h_1, h_2, ..., h_N$ from left to right along the line. Since you are the mayor of ...
2
1,024
batch
24
["implementation", "ad-hoc", "data structures", "dynamic programming"]
49
CCO-2023-Canadian_Computing_Olympiad-d2p1
CCO
Canadian_Computing_Olympiad
d2p1
# 2023 Canadian Computing Olympiad ## Day 2, Problem 1: Flip it and Stick it #### Time Limit: 1 second #### Problem Description Finn is playing a game of “Flip it and Stick it” which is abbreviated as FiSi. FiSi is a one-player game played on two strings, S and T, of 0s and 1s. Finn is allowed to make moves of the f...
1
1,024
batch
21
["case analysis", "ad-hoc"]
50
CCO-2023-Canadian_Computing_Olympiad-d2p2
CCO
Canadian_Computing_Olympiad
d2p2
# 2023 Canadian Computing Olympiad # Day 2, Problem 2 # Travelling Trader ## Time Limit: 2 seconds ## Problem Description A trader would like to make a business of travelling between cities, moving goods from one city to another in exchange for a profit. There are $N$ cities labelled $1, \dots, N$ and $N - 1$ roads....
2
1,024
batch
26
["dynamic programming", "case analysis", "ad-hoc", "tree", "implementation", "tree dp"]
51
CCO-2023-Canadian_Computing_Olympiad-d2p3
CCO
Canadian_Computing_Olympiad
d2p3
# 2023 Canadian Computing Olympiad Day 2, Problem 3 Triangle Collection **Time Limit:** 4 seconds **Problem Description** Alice has a collection of sticks. Initially, she has $c_l$ sticks of length $l$ for each $l = 1, ..., N$. Alice would like to use her sticks to make some isosceles triangles. An isosceles triang...
1
1,024
batch
22
["data structures", "greedy", "prefix sum", "segment tree"]
52
CCO-2023-Canadian_Computing_Competition_Junior-j1
CCO
Canadian_Computing_Competition_Junior
j1
### Problem J1: Deliv-e-droid ### Problem Description In the game, Deliv-e-droid, a robot droid has to deliver packages while avoiding obstacles. At the end of the game, the final score is calculated based on the following point system: * Gain 50 points for every package delivered. * Lose 10 points for every col...
3
512
batch
2
["arithmetic", "mathematics", "implementation"]
53
CCO-2023-Canadian_Computing_Competition_Junior-j2
CCO
Canadian_Computing_Competition_Junior
j2
# Problem J2: Chili Peppers ## Problem Description Ron is cooking chili using an assortment of peppers. The spiciness of a pepper is measured in Scolville Heat Units (SHU). Ron's chili is currently not spicy at all, but each time Ron adds a pepper, the total spiciness of the chili increases by the SHU value of that ...
3
512
batch
2
["arithmetic", "mathematics", "implementation", "string"]
54
CCO-2023-Canadian_Computing_Competition_Junior-j3
CCO
Canadian_Computing_Competition_Junior
j3
# Problem J3: Special Event #### Problem Description You are trying to schedule a special event on one of five possible days. Your job is to determine on which day you should schedule the event, so that the largest number of interested people are able to attend. #### Input Specification The first line of input wil...
3
512
batch
3
["implementation", "brute force", "string"]
55
CCO-2023-Canadian_Computing_Competition_Junior-j5
CCO
Canadian_Computing_Competition_Junior
j5
# Problem J5: CCC Word Hunt ## Problem Description In the CCC Word Hunt, words are hidden in a grid of letters. The letters of a hidden word always appear in order on horizontal, vertical, or diagonal line segments in one of two ways. One way is for the letters of a word to appear on one line segment. The other way i...
3
512
batch
11
["implementation", "graph theory", "graph traversal", "dfs"]
56
CCO-2023-Canadian_Computing_Competition_Junior-s1j4
CCO
Canadian_Computing_Competition_Junior
s1j4
# Problem J4/S1: Trianglane ## Problem Description Bocchi the Builder just finished constructing her latest project: a laneway consisting of two rows of white equilateral triangular tiles. However, at the last moment, disaster struck! She accidentally spilled black paint on some of the tiles. Now, some of the tiles a...
1
512
batch
7
["implementation", "geometry"]
57
CCO-2024-Canadian_Computing_Competition_Senior-s1
CCO
Canadian_Computing_Competition_Senior
s1
# Problem S1: Hat Circle ## Problem Description At a recent social gathering, $N$ people sit around a circular table, where $N$ is even. The seats are numbered clockwise from 1 to $N$. Each person is wearing a hat with a number on it. Specifically, the person at seat $i$ is wearing a hat with the number $H_i$ on it. ...
1
512
batch
3
["arithmetic", "mathematics", "implementation"]
58
CCO-2024-Canadian_Computing_Competition_Senior-s2
CCO
Canadian_Computing_Competition_Senior
s2
# Problem S2: Heavy-Light Composition ## Problem Description In a string containing only lowercase letters of the alphabet (“a” through "z"), we say a letter is *heavy* if it appears more than once in the string, and *light* otherwise. We will be given a number of strings. For each string, we would like to determine...
3
512
batch
4
["implementation", "string"]
59
CCO-2024-Canadian_Computing_Competition_Senior-s3
CCO
Canadian_Computing_Competition_Senior
s3
## Problem S3: Swipe ## Problem Description Swipe is a new mobile game that has recently exploded in popularity. In each level of Swipe, you are given 2 rows of integers that can be represented as arrays A and B of size N. The objective of Swipe is to beat each level by turning array A into array B. There are two sw...
1
512
batch
13
["ad-hoc", "two pointers"]
60
CCO-2024-Canadian_Computing_Competition_Senior-s4
CCO
Canadian_Computing_Competition_Senior
s4
## Problem S4: Painting Roads ### Problem Description Alanna, the mayor of Kitchener, has successfully improved the city's road plan. However, a travelling salesperson from the city of RedBlue complained that the roads are not colourful enough. Alanna's second job is to paint some of the roads. Kitchener's road plan...
1
512
batch
16
["connectivity", "constructive", "graph traversal", "spanning tree"]
61
CCO-2024-Canadian_Computing_Competition_Senior-s5
CCO
Canadian_Computing_Competition_Senior
s5
# Problem S5: Chocolate Bar Partition ## Problem Description Maxwell has a chocolate bar that he wants to share with his friends. The chocolate bar can be represented as a 2 by $N$ array of integers $T_{i,j}$, the tastiness of each square. Maxwell would like to split the entire chocolate bar into connected parts such...
1
512
batch
21
["dynamic programming"]
62
CCO-2024-Canadian_Computing_Olympiad-d1p1
CCO
Canadian_Computing_Olympiad
d1p1
# 2024 Canadian Computing Olympiad # Day 1, Problem 1: Treasure Hunt **Time Limit:** 4 seconds ## Problem Description Perry the Pirate is sailing the seven seas! He has a map consisting of $N$ islands connected by a network of $M$ sea routes. The $i$-th sea route connects islands $a_i$ and $b_i$ and costs $c_i$ coin...
4
1,024
batch
16
["dijkstra", "shortest path", "graph theory", "dynamic programming"]
63
CCO-2024-Canadian_Computing_Olympiad-d1p2
CCO
Canadian_Computing_Olympiad
d1p2
# 2024 Canadian Computing Olympiad # Day 1, Problem 2 # Pizza Party **Time Limit:** 4 seconds ## Problem Description Troy is fleshing out the details of his latest initiative, HackCCO! Everyone knows that the biggest appeal of any hackathon is the free food. As such, to ensure the unparalleled success of HackCCO, Tr...
4
1,024
batch
18
["data structures", "greedy", "tree map", "longest increasing sequence"]
64
CCO-2024-Canadian_Computing_Olympiad-d1p3
CCO
Canadian_Computing_Olympiad
d1p3
# 2024 Canadian Computing Olympiad # Day 1, Problem 3 # Summer Driving **Time Limit:** 6 seconds ## Problem Description In Ontario, there are $N$ cities numbered from 1 to $N$. There are $N - 1$ roads numbered from 1 to $N - 1$, where the $i$-th road connects city $u_i$ and city $v_i$. It is possible to travel from ...
6
1,024
batch
24
["game theory", "dynamic programming", "minimax", "tree", "graph traversal"]
65
CCO-2024-Canadian_Computing_Olympiad-d2p1
CCO
Canadian_Computing_Olympiad
d2p1
# 2024 Canadian Computing Olympiad ## Day 2, Problem 1 # Infiltration ## Time Limit: 1 second ## Problem Description Ondrej and Edward are spies and they are going to take down the evil organization AQT. To do so, they will need to infiltrate the AQT base. The base can be modelled as a tree with `N = 100` rooms, lab...
1
1,024
batch
21
["ad-hoc", "constructive"]
66
CCO-2024-Canadian_Computing_Olympiad-d2p2
CCO
Canadian_Computing_Olympiad
d2p2
## 2024 Canadian Computing Olympiad ### Day 2, Problem 2: Heavy Light Decomposition **Time Limit:** 4 seconds #### Problem Description In an array containing only positive integers, we say an integer is heavy if it appears more than once in the array, and light otherwise. An array is good if the integers in the ar...
4
1,024
batch
22
["line sweep", "data structures", "segment tree", "dynamic programming"]
67
CCO-2024-Canadian_Computing_Olympiad-d2p3
CCO
Canadian_Computing_Olympiad
d2p3
# 2024 Canadian Computing Olympiad Day 2, Problem 3 Telephone Plans Time Limit: 4 seconds ## Problem Description The “Dormi's Fone Service" is now the only telephone service provider in CCOland. There are $N$ houses in CCOland, numbered from 1 to $N$. Each telephone line connects two distinct houses such that all th...
4
1,024
batch
21
["data structures", "segment tree", "connectivity", "union-find"]
68
CCO-2024-Canadian_Computing_Competition_Junior-j1
CCO
Canadian_Computing_Competition_Junior
j1
# Problem J1: Conveyor Belt Sushi ### Problem Description There is a new conveyor belt sushi restaurant in town. Plates of sushi travel around the restaurant on a raised conveyor belt and customers choose what to eat by removing plates. Each red plate of sushi costs $3, each green plate of sushi costs $4, and each b...
3
512
batch
1
["arithmetic", "mathematics"]
69
CCO-2024-Canadian_Computing_Competition_Junior-j2
CCO
Canadian_Computing_Competition_Junior
j2
# Problem J2: Dusa And The Yobis ## Problem Description Dusa eats Yobis, but only Yobis of a certain size. If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size. For example, if Dusa is of size 10 and it encounters a Yobi of size 6, Dusa eats the Yobi and expands to size 10 + ...
3
512
batch
3
["arithmetic", "simulation", "mathematics", "implementation"]
70
CCO-2024-Canadian_Computing_Competition_Junior-j3
CCO
Canadian_Computing_Competition_Junior
j3
# Problem J3: Bronze Count ## Problem Description After completing a competition, you are struck with curiosity. How many participants were awarded bronze level? Gold level is awarded to all participants who achieve the highest score. Silver level is awarded to all participants who achieve the second highest score. ...
3
512
batch
7
["implementation", "sorting"]
71
CCO-2024-Canadian_Computing_Competition_Junior-j4
CCO
Canadian_Computing_Competition_Junior
j4
# Problem J4: Troublesome Keys ## Problem Description As Alex is typing, their keyboard is acting strangely. Two letter keys are causing trouble: - One letter key displays the same wrong letter each time it is pressed. Alex calls this key the *silly key*. Oddly, Alex never actually tries to type the wrong letter dis...
3
512
batch
10
["implementation", "brute force", "string"]
72
CCO-2024-Canadian_Computing_Competition_Junior-j5
CCO
Canadian_Computing_Competition_Junior
j5
# Problem J5: Harvest Waterloo ### Problem Description There is a wildly popular new harvest simulation game called Harvest Waterloo. The game is played on a rectangular pumpkin patch which contains bales of hay and pumpkins of different sizes. To begin the game, a farmer is placed at the location of a pumpkin. The ...
3
512
batch
9
["graph traversal", "bfs", "graph theory", "dfs"]
73
COCI-2023-CONTEST_#3-baltazar
COCI
CONTEST_#3
baltazar
# Task Baltazar Baltazar decided to go on a vacation. Currently, he is in Baltazargrad and wants to travel to Primošten. To get there, he has to go through many cities. There are *n* cities, and they are connected with *m* two-way roads. Baltazargrad is labeled as city no. 1, and Primošten as city no. *n*. Baltazar i...
4
512
batch
21
["shortest path", "dijkstra", "graph theory"]
74
COCI-2023-CONTEST_#3-bomboni
COCI
CONTEST_#3
bomboni
# Task Bomboni Iva is a big fan of candy! In front of her is an $n \times n$ field filled with candy and obstacles. Iva is currently in the upper left cell of the field and by moving only down and right she will travel to the lower right cell. The cell Iva is currently in does not contain an obstacle. In every cell, ...
2
512
batch
16
["prime", "number theory", "grid traversal", "dynamic programming"]
75
COCI-2023-CONTEST_#3-dirigent
COCI
CONTEST_#3
dirigent
# Task Dirigent Winter school of informatics ends with a traditional dance. There are *n* students who participate. Each of them has a unique label between 1 and *n*. First, conductor Krešo orders the students to form a circle such that each student holds hands with two other students. Alenka is wondering if it is p...
1
512
batch
13
["data structures", "simulation", "modular arithmetic", "combinatorics"]
76
COCI-2023-CONTEST_#3-estimathon
COCI
CONTEST_#3
estimathon
# Task Estimathon Paula and Domagoj are organizing an exciting team competition called Estimathon. They have already prepared the questions, and now they are arranging the room for the quiz. Before you could blink, Domagoj had already placed $n$ tables in the room. Now they need to add chairs. They have very colourfu...
1
512
batch
9
["implementation", "ad-hoc", "mathematics"]
77
COCI-2023-CONTEST_#3-skrivaca
COCI
CONTEST_#3
skrivaca
# Task Skrivača Marin and Luka are playing a popular kids game called *Hide and Seek (Skrivača)*. They are playing in their house which has *n* rooms, and *m* pairs of rooms are connected by a door. Rooms are labeled from 1 to *n* and for each pair of rooms there exists a path from one room to another. Luka has thoug...
2
512
batch
21
["shortest path", "shortest paths", "bfs", "dynamic programming"]
78
COCI-2023-CONTEST_#5-diskurs
COCI
CONTEST_#5
diskurs
![](_page_0_Picture_0.jpeg) # Task Diskurs You are given $n$ non-negative integers $a_1, a_2, ..., a_n$ less than $2^m$. For each of them, you are to find the maximum possible Hamming distance between it and some other element of the array $a$. The Hamming distance of two non-negative integers is defined as the numb...
2
512
batch
16
["data structures", "greedy", "bitmask", "trie"]
79
COCI-2023-CONTEST_#5-kalendar
COCI
CONTEST_#5
kalendar
# Task Kalendar Magdalena likes calendars, and she makes her own calendar for each month. Each day of the month is represented with exactly three characters: - If the day number is single-digit, then it is represented as '..X'. For example, the number 7 is represented as '..7'. - If the day number is double-digit, t...
1
512
batch
5
["simulation", "grid traversal", "string"]
80
COCI-2023-CONTEST_#5-logaritam
COCI
CONTEST_#5
logaritam
# Task Logaritam Hrvoje has recently learned about the logarithm function. He really likes the property $\log(xy) = \log(x) + \log(y)$, for each pair of positive real numbers $x$ and $y$. He is actually not interested in the function itself, but in logarithmic sequences. A logarithmic sequence of length $n$ is a sequ...
1
512
batch
16
["prime", "mathematics"]
81
COCI-2023-CONTEST_#5-slasticarnica
COCI
CONTEST_#5
slasticarnica
# Task Slastičarnica *There is a new bakery in town! Come and try delicious cakes from Dodo's bakery!* The bakers have prepared *n* cakes, the *i*-th of which has sweetness *a<sub>i</sub>*. They are displayed on a long table in the given order. There are *q* people waiting in line to order the best cakes in town. Eac...
2
512
batch
18
["segment tree", "range queries", "binary search", "dynamic programming"]
82
COCI-2023-CONTEST_#5-zastave
COCI
CONTEST_#5
zastave
## Task Zastave After an exhausting day of preparing COCI, after sleeping for only three hours and in intervals of 20 minutes, and finally after naughty Patrick and Josip got on his nerves, Vito fell asleep. Vito was always a pacifist and as a sign of his resignation in front of the disobedience of his (un)reliable f...
1
512
batch
21
["geometry", "optimization", "parametric search", "lagrange multipliers"]
83
COCI-2023-CONTEST_#4-7krokods
COCI
CONTEST_#4
7krokods
# Task 7Krokods When he is not making videos for his [YouTube channel](https://www.youtube.com/channel/UCLeaG05z_yu0xK4CyM8byuQ), the famous programmer influencer Krokod likes to play boardgames with his friend Paula. He wants to play the game *7Krokods*, but Paula doesn't like complex games, so Krokod decided that th...
1
512
batch
9
["enumeration"]
84
COCI-2023-CONTEST_#4-bojanje
COCI
CONTEST_#4
bojanje
# Croatian Open Competition in Informatics # Round 4, February 11th 2023 # Task Bojanje ## 1 second / 512 MiB / 110 points Oliver is a rubber duck that, not only finds bugs, but also likes to paint. His latest painting has *n* parts, each coloured with a unique colour. After he got a lot of critiques his painting is ...
1
512
batch
18
["fast exponentiation", "modular arithmetic", "markov chain", "combinatorics"]
85
COCI-2023-CONTEST_#4-mreza
COCI
CONTEST_#4
mreza
# Task Mreža The city mayor Mirko lives in a city with $n$ neighborhoods connected with $n - 1$ bidirectional roads such that from any neighborhood it is possible to reach every other neighborhood. Mirko wants to upgrade some roads to reduce traffic. For every road, we know the current speed $v_i$ vehicles drive on i...
5
512
batch
21
["segment tree"]
86
COCI-2023-CONTEST_#4-vrsta
COCI
CONTEST_#4
vrsta
# Task Vrsta Domagoj's favorite school subject is P.E. Every P.E. class starts with warm-up exercises. The teacher has an interesting way of choosing the student who will lead the warm-up. The students stand in a line sorted by their height. The teacher will choose the student that is standing in the middle of the lin...
1
512
batch
16
["order statistics", "binary indexed tree", "coordinate compression"]
87
COCI-2023-CONTEST_#4-zrinka
COCI
CONTEST_#4
zrinka
# Task Zrinka You are given two arrays of length *n* and *m* respectively, which consist only of 0's and 1's. Your task is to replace every zero with an even positive integer and every one with an odd positive integer. After replacements both arrays should be increasing and you can use each positive integers at most ...
1
512
batch
13
["minimum maximum", "grid traversal", "binary search", "dynamic programming"]
88
COCI-2024-CONTEST_#3-cesta
COCI
CONTEST_#3
cesta
Task Slučajna Cesta 3 seconds / 512 MiB / 110 points Task Slučajna Cesta Vito lives in a city with *n* parks labeled from 1 to *n*. The parks are connected with *n* - 1 roads such that there is a path between any two pairs of parks. Every park has some beauty value, beauty value of *i*-th park is *vi*. Last night Vit...
3
512
batch
18
["dynamic programming", "linear algebra", "tree", "modular arithmetic", "expected value"]
89
COCI-2024-CONTEST_#3-eurokod
COCI
CONTEST_#3
eurokod
# Task Eurokod This year, for the first time, the *Eurokod* is being held, an international competition in writing beautiful and readable code! There are *n* contestants participating in the competition, labeled with numbers from 1 to *n*, and each of them has written a code. Their codes are evaluated by an associat...
1
512
batch
9
["implementation", "sorting", "custom comparator"]
90
COCI-2024-CONTEST_#3-milano
COCI
CONTEST_#3
milano
# Task Milano C.le Silvia is at the Milano Centrale railway station and she noticed that the station has a lot of platforms. She thought that there are too many of them, so she decided to check how many of them are actually needed. Silvia also noticed an interesting fact that holds at this station: ![](_page_0_Pictu...
1
512
batch
13
["binary search"]
91
COCI-2024-CONTEST_#3-restorani
COCI
CONTEST_#3
restorani
# Task Restorani Coming to Szeged, Mr. Malnar is, as usual, obliged to get acquainted with the local culture, and thus try all traditional meals, culinary specialties, and local drinks. We can imagine Szeged as *n* interesting locations numbered from 1 to *n* connected by *n* − 1 bidirectional roads in such a way tha...
2
512
batch
21
["eulerian path", "tree dp", "dfs"]
92
COCI-2024-CONTEST_#3-vrsar
COCI
CONTEST_#3
vrsar
# Task Vrsar Vrsar is a small coastal town consisting of *n* hills. Surprisingly, all the hills, when viewed from the sea, are arranged one behind the other so that the *i*-th hill is *x<sub>i</sub>* meters away from the sea. At the top of each hill, there is an ice rink. All ice rinks open simultaneously every day, b...
1
512
batch
25
["segment tree", "piecewise functions", "offline queries", "dynamic programming"]
93
COCI-2024-CONTEST_#5-bitovi
COCI
CONTEST_#5
bitovi
# Task Bitovi What came first, the chicken or the egg? Is it better to live a hundred years as a millionaire or seven days in poverty? How to become a chess grandmaster? How to raise blinds? How to pass the final exams? How to train a dragon? These are interesting questions we can ponder only after the competition, bu...
1
512
batch
24
["set", "greedy", "graph theory", "bitmask"]
94
COCI-2024-CONTEST_#5-piratski
COCI
CONTEST_#5
piratski
# Task Piratski kod Captain Marrrtina, together with her pirate crew, after three months of searching for long lost treasure belonging to the most famous Italian pirate finally dug up chest full of treasure. But to unlock the chest she needs a secret combination which is described in a message in a bottle next to the ...
2
512
batch
20
["string sequences", "number theory", "combinatorics", "dynamic programming"]
95
COCI-2024-CONTEST_#5-rolete
COCI
CONTEST_#5
rolete
# Task Rolete One Saturday Luka woke up from an afternoon nap and remembered: today is COCI! There was only one thing that he needed to do before the contest: raise the blinds. Luka has *n* blinds in his room, where the *i*-th one is lowered by *a<sub>i</sub>* centimeters from the top of the window. He can raise the ...
2
512
batch
18
["sorting", "prefix sum", "convex hull", "ternary search"]
96
COCI-2024-CONTEST_#5-trokut
COCI
CONTEST_#5
trokut
### Croatian Open Competition in Informatics ### Round 5, March 16th 2024 # Task Trokut Ivan and Lucija are on a journey to a place far... far away. They know that the journey will last a long time and that they will be bored at some point. While they were thinking about what to do, Lucija came up with a game. She d...
1
512
batch
24
["game theory", "number theory"]
97
COCI-2024-CONTEST_#5-zlagalica
COCI
CONTEST_#5
zlagalica
# Task Zlagalica Little Maja has always loved puzzles. And since everyone knew that for a long time now, it is no wonder that one sunny day, Maja received an odd puzzle as a gift. This puzzle has *n* pieces. Each piece has rectangular shape and is of a certain color. Also, each piece has 2 numbers written on its back...
1
512
batch
15
["data structures", "simulation", "grid traversal", "coordinate geometry"]
98
COCI-2024-CONTEST_#4-bingo
COCI
CONTEST_#4
bingo
# Task Bingo It's time to play Bingo! To play Bingo, you need a game master and a drum with 90 balls, each containing a number from 1 to 90, such that every number appears on exactly one ball. Before the game starts, the game master gives each of the $n$ players a board of size 5 × 5. Each field of the board contain...
1
512
batch
9
["ad-hoc", "simulation", "grid traversal"]
99
COCI-2024-CONTEST_#4-knjige
COCI
CONTEST_#4
knjige
# Task Knjige Marko was at the *Interliber* book fair, and he bought $n$ books. The attraction of the $i$-th book is $k_i$. Marko arranged the books on the shelf according to their attraction values, so the first book from the left is the least attractive, and every next one to the right is more or equally attractive ...
1
512
batch
17
["greedy", "prefix sum", "array"]