Edvard's blog

By Edvard, 12 years ago, In English

Всем привет!

Сегодня на этапе открытого кубка была задача с добавлением точки в выпуклую оболочку. Эта задача просто решается если уметь быстро строить касательные к выпуклому многоугольнику. Я слышал, что вроде такой алгоритм есть. Кто-нибудь знает где почитать можно или как он примерно работает?

Full text and comments »

  • Vote: I like it
  • +14
  • Vote: I do not like it

By Edvard, 13 years ago, translation, In English

A. Postcards and photos

We will move from the left of string to the right. When we passed the whole string, or in the hands of us have 5 pieces, or current object is different from what we hold in our hands, we remove all the items in the pantry. The answer to the problem is the number of visits to the pantry.

The complexity is O(n).

B. Permutation

We can count the number of integers from 1 to n, which occur in sequence at least once. Then the answer is n minus that number.

The complexity is O(n).

C. History

Denote a[i], b[i] - ends of the i-th event. Let's sort pairs (a[i], b[i]) by a[i] and iterate over all pairs. Denote rg the maximal b[i] from already processed. If current b[i] < rg than we must increment answer by one. If b[i] > rg than we must assign rg by b[i].

The complexity is O(n logn).

D. Palindromes

Let's preprocess array cnt[i][j] - the minimal number of changes tha we must do to make substring from position i to j palindrom. We can easy calc cnt[i][j] with complexity O(n^3). Now we can calculate dynamic programming z[i][j] - minimal number of changes that we can do to split prefix of length i into j palindromes. In begining we must assign z[i][j] = infinity for all (i, j) and assign z[0][0] = 0. If we want to make updates from state (i, j) we must fix the length of j-th palindrom - len. We can update z[i + len][j + 1] by value z[i][j] + cnt[i][i + len - 1]. Answer to the problem is the min(z[n][i]), where n is the length of string and i from range [1, k].

The complexity is O(n^3).

E. Last Chance

Let's replace all vowels by -1 and all consonants by +2. Obviously substring from position i to j is good if sum in the substring [i, j] is nonnegative. Denote this sum by sum[i][j]. Obviously sum[i][j] = p[j + 1] - p[i], where p[i] is the sum of first i elements. Now for all i we want to find maximal j such that j >= i and sum[i][j] >= 0. For this let's sort the array of (p[i], i) and build segment tree on this array by i. Let's iterate over all p[i] in nondescending order. Obsiously for fixed i we have that j = max(index[i]), where index[i] is the index of i-th partial sum in nondescending order and i from range [x, n], where x is the position of the first partial sum with value p[i] in sorted array. Than we must update position i by value of negative infinity and update answer by j - i.

The complexity is O(n logn).

Full text and comments »

  • Vote: I like it
  • +23
  • Vote: I do not like it

By Edvard, 13 years ago, translation, In English

Hi everyone!!!

It remains less than 10 hours before Codeforces Beta Round #98 (Div. 2). This round was prepared for you by me, proposed the ideas of the problems. Traditionally, RAD made sure that there is no bugs and that the statements are normal, and Delinur translated the statements into English. Thanks to them!

If you decide to participate in the round you have to help the boy Polycarpus and his classmate Innocentius in all the difficulties they face. The more you help them, the higher you will be placed in the standing.

I hope the problems will be interesting not only for Div. 2 participants, but the participants rated higher than 1699.

I will continue the story about myself (beginning of story in the previous blog entry). Besides programming I love sports. Within a few years before I started writing code, I was seriously involved in rowing. And before that I was going in for almost all sports :-): karate, soccer, hockey and so much more interesting. Now I love (especially at the training camp) to play volleyball and table tennis. I decided to prepare this round despite the fact that during the past two weeks, much has changed inside Codeforces and I took part in this.

Following the fashion trends I have changed my avatar.

Good luck for all on the round!

UPD:

Contest is finished, results are final, ratings are updated.

Top 10 (Div. 2)

3. stx2

Congratulations to winners!!!

Full text and comments »

  • Vote: I like it
  • +141
  • Vote: I do not like it

By Edvard, 13 years ago, translation, In English

Hi everyone!!!

Earlier this month, I joined the Codeforces team. I'm now running a small improvement on the project, as well as adding some functionality. For example, you might notice that yesterday on your personal page appeared a new tab with the results of your performance. I also took part in the implementation of several improvements, about which previously wrote MikeMirzayanov. I hope that my participation in the project will bring much benefit.

I want to thank MikeMirzayanov and MaximShipko, without them I could not write a single line.

Little information about me. I am study in Saratov State University. I began programming in the first year in university, when passed (from last place :-)) selection to the Olympiad training center for programmers in SSU. Until last month, I wrote code only for olympiads and don't have any experience of production programming. I hope this does not prevent me to reach the heights in this very interesting work.

Pleased and a little tired Davtyan Edvard

UPD: 1. User contests page is changed. Added column with rating after contest 2. Added page with all comments of any user.

UPD2: 3. Added a page with all problems (it can be accessed directly from the contest). Now it is possible to see all problems of contest and print it out (each problem will be printed on a separate page).

Full text and comments »

  • Vote: I like it
  • +165
  • Vote: I do not like it

By Edvard, 14 years ago, translation, In English

Analysis for problem "D. Knights".

Denote the number of fences surrounding the control point number i through cnti. Also denote cntij - the number of fences surrounding point i and point j. Then the answer to the query (i, j) is cnti + cntj - cntij. Clearly, that we can calculate all the values cnti with time O(n * m). The problem is the fast computation of the values cntij. And then suggests two solutions: a simple and not very much. Simple is as follows: create for every point i a bitset, j-th is equal to 1 if the j-th fence surrounds the point number i. Then, obviously cntij = count(zi & zj), where count(a) - the number of ones in bitset a. Now another solution. Add another fence with a center at (0, 0) and infinite radius. We construct a graph whose vertices are the fences as follows: we draw an arc from i to j, if the i-th fence is a fence with the minimum radius surrounding the fence number j. Obviously we get a directed tree rooted at the fence of infinite radius. Also, for each control point will find idxi - number of the fence with minimum radius  surrounding the i-th control point. Then cntij = distij + distji, where distij - distance from vertex i to the lowest common ancestor of verticex i ans j. With the implementation problems should not arise, because in the first solution could write bitset himself or use the standard bitset from STL (for those who write in C++), while in the second solution we could preprocess all the lca with time O(n2).

Full text and comments »

  • Vote: I like it
  • +10
  • Vote: I do not like it