## Palindromic Hamiltonian Path solution codeforces – You are given a simple undirected graph with nn vertices, nn is even. You are going to write a letter on each vertex.

You are given a simple undirected graph with nn vertices, nn is even. You are going to write a letter on each vertex. Each letter should be one of the first kk letters of the Latin alphabet. A path in the graph is called Hamiltonian if it visits each vertex exactly once. A string is called palindromic if it reads the … Read more

## Playoff Restoration solution codeforces – 2k2k teams participate in a playoff tournament. The tournament consists of 2k−12k−1 games

2k2k teams participate in a playoff tournament. The tournament consists of 2k−12k−1 games. They are held as follows: first of all, the teams are split into pairs: team 11 plays against team 22, team 33 plays against team 44 (exactly in this order), and so on (so, 2k−12k−1 games are played in that phase). When a team loses a game, it is eliminated, and each game results … Read more

## Inconvenient Pairs solution codeforces – There is a city that can be represented as a square grid with corner points in (0,0)(0,0) and (106,106)(106,106).

Inconvenient Pairs solution codeforces There is a city that can be represented as a square grid with corner points in (0,0)(0,0) and (106,106)(106,106). The city has nn vertical and mm horizontal streets that goes across the whole city, i. e. the ii-th vertical streets goes from (xi,0)(xi,0) to (xi,106)(xi,106) and the jj-th horizontal street goes from (0,yj)(0,yj) to (106,yj)(106,yj). All streets are bidirectional. Borders of the city are streets as well. There … Read more

## Jury Meeting solution codeforces – nn people gathered to hold a jury meeting of the upcoming competition, the ii-th member of the jury came up with aiai tasks, which they want to share with each other.

Jury Meeting solution codeforces nn people gathered to hold a jury meeting of the upcoming competition, the ii-th member of the jury came up with aiai tasks, which they want to share with each other. First, the jury decides on the order which they will follow while describing the tasks. Let that be a permutation pp of numbers from 11 to nn (an array of … Read more

## Chess Tournament solution codeforces – A chess tournament will be held soon, where nn chess players will take part. Every participant will play one game against every other participant.

Chess Tournament solution codeforces A chess tournament will be held soon, where nn chess players will take part. Every participant will play one game against every other participant. Each game ends in either a win for one player and a loss for another player, or a draw for both players. Each of the players has their own … Read more

## Balanced Substring solution codeforces – You are given a string ss, consisting of nn letters, each letter is either ‘a’ or ‘b’. The letters in the string are numbered from 11 to nn.

Balanced Substring solution codeforces You are given a string ss, consisting of nn letters, each letter is either ‘a‘ or ‘b‘. The letters in the string are numbered from 11 to nn. s[l;r]s[l;r] is a continuous substring of letters from index ll to rr of the string inclusive. A string is called balanced if the number of letters ‘a‘ in it is equal to the number … Read more