Codeforces Round 1045 (Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2134 Codeforces Round 1045 (Div. 2) FINISHED False 7200 20186723 Aug. 26, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2379 ) E Power Boxes PROGRAMMING constructive algorithms dp interactive

This is an interactive problem. You are given (n) boxes, indexed from (1) to (n). The boxes look identical, but each one has a hidden power value (a_i), which is either (1) or (2). You want to determine the power value of each box. To do so, you conduct the following experiment. Initially, the (i)-th box is placed at coordinate (i) on a number line ((1 \le i \le n)). You are allowed to perform the following two types of queries: " swap (x) " ((1 \le x \le n - 1)): Swap the boxes currently located at coordinates (x) and (x + 1). Note that this change is permanent and affects all subsequent queries. " throw (x) " ((1 \le x \le n)): Throw a ball at the box located at coordinate (x). The ball travels (p) units forward to coordinate (x + p) if the power value of the box is (p). If there is a box at the new coordinate, the ball jumps again using the power of that box. This continues until the ball lands on a coordinate without a box. As a response, you are given the total number of jumps the ball made before stopping. Your task is to determine the power value of each box using no more than (\left\lceil \frac{3n}{2} \right\rceil) queries in total, counting both swap and throw queries. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 500)). The description of the test cases follows. The first and the only line of each test case contains a single integer (n) ((2 \le n \le 1000)) — the number of boxes. It is guaranteed that the sum of (n) over all test cases does not exceed (1000). The interaction for each test case begins by reading the integer (n). To make a query, output a line in one of the following formats: " swap (x) " (without quotes) ((1 \le x \le n - 1)): Swap the boxes currently located at coordinates (x) and (x + 1). " throw (x) " (without quotes) ((1 \le x \le n)): T

Tutorials

145832

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
335711629 og.kostya E Aug. 26, 2025, 5:57 p.m. OK C# 13 TESTS 27 124 0

remove filters

Back to search problems