Change the structure of codeforces solutions

This commit is contained in:
Ivan R. 2024-12-21 14:16:51 +05:00
parent c90be6e38d
commit 00de46a9d1
Signed by: lumin
GPG key ID: E0937DC7CD6D3817
30 changed files with 41 additions and 22 deletions

View file

@ -0,0 +1,3 @@
# Round 923 (div. 3)
[Contest page](https://codeforces.com/contest/1927/)

View file

@ -1,10 +1,11 @@
# A. Make it White
[Codeforces.com](https://codeforces.com/contest/1927/problem/A)
[Task page](https://codeforces.com/contest/1927/problem/A)
You have a horizontal strip of n cells. Each cell is either white or black.
You can choose a continuous segment of cells once and paint them all white. After this action, all the black cells in this segment will become white, and the white ones will remain white.
You can choose a continuous segment of cells once and paint them all white.
After this action, all the black cells in this segment will become white, and the white ones will remain white.
What is the minimum length of the segment that needs to be painted white in order for all n cells to become white?
@ -23,7 +24,8 @@ It is guaranteed that at least one cell of the given strip is black.
## Output
For each test case, output a single number — the minimum length of a continuous segment of cells that needs to be painted white in order for the entire strip to become white.
For each test case, output a single number — the minimum length of a continuous segment of cells that
needs to be painted white in order for the entire strip to become white.
## Example

View file

@ -1,13 +1,15 @@
# B. Following the String
[Codeforces.com](https://codeforces.com/contest/1927/problem/B)
[Task page](https://codeforces.com/contest/1927/problem/B)
Polycarp lost the string s of length n consisting of lowercase Latin letters, but he still has its trace.
The trace of the string s
is an array a of n integers, where ai is the number of such indices j (j<i) that si=sj. For example, the trace of the string abracadabra is the array `[0,0,0,1,0,2,0,3,1,1,4]`.
is an array a of n integers, where ai is the number of such indices j (j<i) that si=sj.
For example, the trace of the string abracadabra is the array `[0,0,0,1,0,2,0,3,1,1,4]`.
Given a trace of a string, find any string s from which it could have been obtained. The string s should consist only of lowercase Latin letters a-z.
Given a trace of a string, find any string s from which it could have been obtained.
The string s should consist only of lowercase Latin letters a-z.
## Input

View file

@ -1,6 +1,6 @@
# D. Find the Different Ones!
[Codeforces.com](https://codeforces.com/contest/1927/problem/D)
[Task page](https://codeforces.com/contest/1927/problem/D)
You are given an array a of n integers, and q queries.
@ -30,7 +30,8 @@ The third line of each test case contains a single integer q
The next q lines contain two integers each, l and r (1≤l<rn) the boundaries of the query.
It is guaranteed that the sum of the values of n across all test cases does not exceed 2⋅105. Similarly, it is guaranteed that the sum of the values of q across all test cases does not exceed 2⋅105.
It is guaranteed that the sum of the values of n across all test cases does not exceed 2⋅105.
Similarly, it is guaranteed that the sum of the values of q across all test cases does not exceed 2⋅105.
## Output

View file

@ -0,0 +1,3 @@
# Educational Codeforces Round 171 (Rated for Div. 2)
[Contest page](https://codeforces.com/contest/2026/)

View file

@ -1,6 +1,6 @@
# A. Perpendicular Segments
[Codeforces](https://codeforces.com/contest/2026/problem/A)
[Task page](https://codeforces.com/contest/2026/problem/A)
You are given a coordinate plane and three integers `X`, `Y`, and `K`. Find two line segments `AB` and `CD` such that
@ -8,7 +8,7 @@ You are given a coordinate plane and three integers `X`, `Y`, and `K`. Find two
2. 0 ≤ `Ax`, `Bx`, `Cx`, `Dx``X` and 0 ≤ `Ay`, `By`, `Cy`, `Dy``Y`;
3. the length of segment `AB` is at least `K`;
4. the length of segment `CD` is at least `K`;
5. segments `AB` and `CD` are perpendicular: if you draw lines that contain `AB` and `CD`, they will cross at a right angle.
5. segments `AB` and `CD` are perpendicular: if you draw lines that contain `AB` and `CD`, they will cross at a right angle.
Note that it's not necessary for segments to intersect.
Segments are perpendicular as long as the lines they induce are perpendicular.

View file

@ -1,6 +1,6 @@
# B. Black Cells
[Codeforces](https://codeforces.com/contest/2026/problem/B)
[Task page](https://codeforces.com/contest/2026/problem/B)
You are given a strip divided into cells, numbered from left to right from 0 to 1018. Initially, all cells are white.
@ -30,6 +30,7 @@ for which it is possible to paint all the given cells black.
## Example
Input
```

View file

@ -0,0 +1,3 @@
# Refact.ai Match 1 (Codeforces Round 985)
[Contest page](https://codeforces.com/contest/2029/)

View file

@ -1,6 +1,6 @@
# A. Set
[Codeforces](https://codeforces.com/contest/2029/problem/A)
[Task page](https://codeforces.com/contest/2029/problem/A)
You are given a positive integer `k` and a set `S` of all integers from `l` to `r` (inclusive).
@ -19,7 +19,8 @@ Find the maximum possible number of operations that can be performed.
Each test contains multiple test cases. The first line of the input contains a single integer `t`
(1 ≤ `t` ≤ 104) — the number of test cases. The description of test cases follows.
The only line of each test case contains three integers `l`, `r`, and `k` (1 ≤ `l``r` ≤ 109, 1 ≤ `k``r` `l` + 1) — the minimum integer in `S`, the maximum integer in `S`, and the parameter `k`.
The only line of each test case contains three integers `l`, `r`, and `k` (1 ≤ `l``r` ≤ 109, 1 ≤ `k``r` `l` + 1) — the minimum
integer in `S`, the maximum integer in `S`, and the parameter `k`.
## Output
@ -64,7 +65,7 @@ In the first test case, initially, S={3,4,5,6,7,8,9}.
One possible optimal sequence of operations is:
- Choose x=4 for the first operation, since there are two multiples of 4 in S: 4 and 8. S becomes equal to {3,5,6,7,8,9};
- Choose x=3 for the second operation, since there are three multiples of 3 in S: 3, 6, and 9. S becomes equal to {5,6,7,8,9}.
- Choose x=3 for the second operation, since there are three multiples of 3 in S: 3, 6, and 9. S becomes equal to {5,6,7,8,9}.
In the second test case, initially, S={4,5,6,7,8,9}. One possible optimal sequence of operations is:

View file

@ -0,0 +1,3 @@
# Codeforces Round 983 (Div. 2)
[Contest page](https://codeforces.com/contest/2032/)

View file

@ -1,6 +1,6 @@
# A. Circuit
[Codeforces](https://codeforces.com/contest/2032/problem/A)
[Task page](https://codeforces.com/contest/2032/problem/A)
Alice has just crafted a circuit with `n` lights and `2n` switches.
Each component (a light or a switch) has two states: on or off. The lights and switches are arranged in a way that:
@ -8,7 +8,7 @@ Each component (a light or a switch) has two states: on or off. The lights and s
- Each light is connected to exactly two switches.
- Each switch is connected to exactly one light. It's unknown which light each switch is connected to.
- When all switches are off, all lights are also off.
- If a switch is toggled (from on to off, or vice versa), the state of the light connected to it will also toggle.
- If a switch is toggled (from on to off, or vice versa), the state of the light connected to it will also toggle.
Alice brings the circuit, which shows only the states of the `2n` switches, to her sister Iris and gives her a riddle:
what is the minimum and maximum number of lights that can be turned on?
@ -74,10 +74,13 @@ In the fourth test case, to have no lights on, the switches can be arranged in t
- Switch 1 and switch 4 are connected to light 1. Since both switches are off, light 1 is also off.
- Switch 2 and switch 6 are connected to light 2. Since both switches are off, light 2 is also off.
- Switch 3 and switch 5 are connected to light 3. Both switches are on, so light 3 is toggled twice from its initial off state, and thus also stays off.
- Switch 3 and switch 5 are connected to light 3. Both switches are on, so light 3 is toggled twice from its initial off state,
and thus also stays off.
And to have 2 lights on, the switches can be arranged in this way:
- Switch 1 and switch 2 are connected to light 1. Since both switches are off, light 1 is also off.
- Switch 3 and switch 4 are connected to light 2. Since switch 3 is on and switch 4 is off, light 2 is toggled once from its initial off state, so it is on.
- Switch 5 and switch 6 are connected to light 3. Since switch 5 is on and switch 6 is off, light 3 is toggled once from its initial off state, so it is on.
- Switch 3 and switch 4 are connected to light 2. Since switch 3 is on and switch 4 is off,
light 2 is toggled once from its initial off state, so it is on.
- Switch 5 and switch 6 are connected to light 3. Since switch 5 is on and switch 6 is off,
light 3 is toggled once from its initial off state, so it is on.

View file

@ -1,3 +0,0 @@
# Round 923
[Contest](https://codeforces.com/contest/1927/)