Блог пользователя savinov

Автор savinov, 12 лет назад, По-русски

Привет, Codeforces!

12 января в 12.00 MSK пройдет очередной 285-й раунд Codeforces. Автором задач являюсь я(Савинов Евгений). Это мой первый раунд на Codeforces и, надеюсь, не последний.

Хочу поблагодарить Сергея Кияна(sokian) и Александра Голованова(Golovanov399) за помощь в подготовке и прорешивании задач, Макса Ахмедова(Zlobober) за неоценимую помощь в подготовке контеста, Алекса Фетисова(AlexFetisov) за прорешивание раунда, Марию Белову(Delinur) за перевод условий на английский язык и, конечно же, Михаила Мирзаянова(MikeMirzayanov) за замечательные системы Codeforces и Polygon.

Кстати, сегодня(11 января) у Михаила Расиховича день рождения, давайте поздравим его с этим!

Раунд состоится в обоих дивизионах. Информация о разбалловке будет опубликована перед началом раунда.

UPD1: Будет использоваться динамическая разбалловка. Задачи расположены в порядке возрастания предполагаемой сложности.

UPD2: Разбор задач можно найти здесь.

  • Проголосовать: нравится
  • +325
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
← Rev. 11  
Проголосовать: нравится -32 Проголосовать: не нравится

It's time is too early in our (Iranian students) timezone because we have to go to school.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится
»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -34 Проголосовать: не нравится

85 is a holy number for Iranians :D

»
12 лет назад, скрыть # |
← Rev. 4  
Проголосовать: нравится +55 Проголосовать: не нравится

Wow ... Mike's Birthday ... That's amazing ... :]


#include <iostream> using namespace std; int main () { cout << "Happy Birthday Mike ! \\:D/" << endl << "Thanks For Everything !!! :D" << endl; return 0; }
»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

Happy birthday MikeMirzayanov.

BTW it seems like tomorrow will be a busy day. Topcoder SRM 645 will take place 5 hours after the end of this round.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Раунд будет в 3 часа дня для меня, главный вопрос придти на работу до или после)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +40 Проголосовать: не нравится

Огромное спасибо MikeMirzayanov за такие замечательные платформы как Codeforces и Polygon. С днём рождения!

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +29 Проголосовать: не нравится

Happy birthday MikeMirzayanov.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -57 Проголосовать: не нравится

dis like me pls

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Information about score distribution will be posted just before the round starts.

Why for almost all contests score distribution reveled just before the contest? What happens if author(s) revel it early?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +91 Проголосовать: не нравится

Поистине гениально устраивать раунд в 12 часов первого рабочего дня в году

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -23 Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +28 Проголосовать: не нравится

Weird timing. Cannot participate due to classes. BTW Happy Birhtday MIKE!!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

thanks :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Happy Birthday dear MikeMirzayanov.

Best wishes, from iran, Hamed

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

The first round in 2015 :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Here in Venezuela Contest will take place at 4:30 a.m T_T i hope my alarm can wake me T_T

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

new year starts , i want to enjoy it as much as possible....:)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -22 Проголосовать: не нравится

Are the problems easy or hard?

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -15 Проголосовать: не нравится

missed contest because of class :(

»
12 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится +19 Проголосовать: не нравится

Hey savinov !
You can use this tag "Happy Birthday Mike ":)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Score distribution?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I'm so happy that I catch the contest. It was a hurry that I went home from the school.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In Codeforces rounds, when two or more separate contests are going to be held, the contests numbers are given by separating with comma. How to detect which contest number belongs to which one? e.g.: Today, two separate contests are scheduled for two divisions in round #285 and the contest link is: http://codeforces.me/contests/501,504. Now, my question is which division belongs to 501? is there any general way to know this for any round before its started? I think, MikeMirzayanov could say the exact answer.Thanks in advance.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

Oh no, dynamic scoring(((

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -31 Проголосовать: не нравится

Why????????

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

in first 10 minutes i was 5th...

But now I'm 260th...

Why I can't never solve C???? :(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Nice problems! :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +158 Проголосовать: не нравится

It's a very bad idea to give numbers in decimal in D :(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What was the aproach to task C?

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +6 Проголосовать: не нравится

    Since the graph is guaranteed to be acyclic, it is a forest and hence it has a leaf. Find one such leaf v. Its neighbor-XOR-sum is the XOR of a single number (the label of its sole neighbor u), so we know there is an edge between v and u. Now decrement u's degree count and XOR u's neighbor-XOR-sum by v (this means removing v from the forest), rinse and repeat.

    To avoid O(n2) time, store the leaves in a stack/queue. After a first pass through the vertices, you will only add at most one vertex at any given time (if u above has degree two, u itself is added to the stack).

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    It is similar to topological sorting

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Как C делать? У меня вот упадет, да и много у кого, мне кажется.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

How to solve problem D/B ( Div2/Div1 ) . thanx in advance :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Верно ли такое решение к Е?

Подвешиваем дерево за какую-нибудь вершину. Считаем хеши в каждой вершине на пути из нее в корень и из корня в нее. Дальше при запросе перебираем длину lcp бин. поиском. Чтобы зачекать префиксы хешами, находим lca каждой пары вершин и с помощью двоичных подъемов и level ancestor (la) получаем хеш префикса.

Итого ...

Можно заменить lca и la на крутые алгоритмы за O(1), но я в них не верю

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +13 Проголосовать: не нравится

Hi,

I find the English version of problem C's description is confusing: " XOR sum of the numbers of vertices adjacent to v ..."

I can only understand it, after look at the Russian version: "XOR-сумма номеров вершин, смежных с v ..."

Seems like google translate did bad job :D

PS: I am out of this round, so I comment here. Good luck for your final rank!

EDITED: The statement should be: " XOR sum of the indexes of vertices adjacent to v ..."

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +11 Проголосовать: не нравится

    The XOR sum of numbers a1, a2, ..., an is simply a1 ^ a2 ^ ...  ^ an; everything XORed together.

    Although yes, "the XOR sum of the numbers of vertices adjacent to v" might be better phrased as "the XOR sum of the labels of vertices adjacent to v".

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Хороший контест, жаль слил его, застопорившись на первой задаче :( Очень понравились чужие решения Div-1 A, без всяких Set-ов, через стек/очередь, до которых я не догадался.

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can somebody please explain to me the second test case for C problem? Thanks in advance.

2
1 1
1 0

Note: (From problem statement) ...were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v...

No idea what second integer means. I do not understand why if both vertex have the same adjacent vertex number then the second number is different.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +198 Проголосовать: не нравится

Am I the only one that thinks that number of interesting problems in that contest equals 0 :/? Though E was interesting a bit, but also pretty tedious to code, but I didn't find anything interesting in BCD, especially D which was "change decimal to binary and do some Gauss", pls. Sorry to say that.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

What was the approach for Div 1 C?

Only observation that I could make is following.

For a fixed index i, let us say there exists an index j s.t. if we can make the entire array an valid palindrome by shuffling values of array from index range [i, j], then we can also do the same for any range [i, k] where k > j. This idea can be used to do binary search over j.

But I had doubts about how to check whether shuffling of current range [i, j] can make the entire array palindrome or not?

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    This, actually, was my exact observation as well. And I have the same question; though I believe I worked out one of the two possible cases..

    • »
      »
      »
      12 лет назад, скрыть # ^ |
      ← Rev. 5  
      Проголосовать: нравится +13 Проголосовать: не нравится

      it can be done without bin_search:

      i = 1
      j = 1
      while(i <= n) {
       while(i > j || !is_it_a_good_range(i,j)) {
        ++j;
        update_set_with_bad_numbers(j);
        update_set_with_bad_numbers(n+1-j);
       }
       update_set_with_bad_numbers(i);
       update_set_with_bad_numbers(n+1-i);
       ++i;
      }
      

      How can we check given range? For every position 'p' in our range:

      1) we increase count[t[p]]

      2) if n+1-p is outside this range, we decrease count[t[n+1-p]] (unless 'p' is a middle position in whole array)

      In std::set let's have numbers such that count[a] is odd or negative (I call them "bad" numbers). A range is good if everything is ok outside range and:

      1) our set is empty, or

      2) our set has one number and count[this number] is positive odd number (it is possible only for odd n)

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +10 Проголосовать: не нравится

    If you observe more, you would found that there are only twe basic range. Let a[1+k] != a[n-k] and for every i < k, a[1+i] == a[n-i]. So the two basic range is [1+k, g] and [h, n-k]. so you don't need to binary and just iterte over g and h.

  • »
    »
    12 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I don't understand. For a string 22134 We can rearrange range [0, 2], but not [0, 3]...

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +34 Проголосовать: не нравится

I guess we can say that the Div. 2 3rd place account I_have_many_girlfriends (which was likely a Div. 2 account) is a cheater (because he has many girlfriends) :P

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I think there is problem about Div1.D and E's time limit. After solved C, I found that the basic solutions for both problems are possible to get TLE. An solution O(n^3 / 64) for C and an solution O(mlogn^2) for E. But the O(n^3 / 64) for C get Ac and O(mlogn^2) for E get TLE. So unfair to someone just as me choose E to solve~

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

кто поможет найти 14 читеров, решивших В? в этом случае, ее стоимость возрастет до 1000 и рейтинг упадет не так сильно))

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +133 Проголосовать: не нравится

Just learnt how reading bignums and asking about j-th bit looks in Java ;

BigInteger x = new BigInteger(in.next());
x.testBit(j);

And in C++?????

Great idea to give them in decimal, that task was surely equally hard to Java and C++ coders.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Whenever the system testing is fast, the rating updates are slow! :D Whenever the system testing is slow, the rating updates are fast!

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +11 Проголосовать: не нравится

epic bug =\ this code passed 7 tests ...

set<int>::iterator it = s.lower_bound(x);
s.erase(it);
upd(*it);
»
12 лет назад, скрыть # |
← Rev. 4  
Проголосовать: нравится -16 Проголосовать: не нравится

thanks savinov :)
your contest has nice problem :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

Approach for problem B.

(Explanation from adurysk)

Finding order of a permutation in a factorial representation
You can represent the order of any permutation like this. If a[0...n-1] is the given array, let la[0...n-1] be another array in which la[i] stores number of j such that j > i and a[j] < a[i] now the order of permutation a[0...n-1] will be la[0] * (n-1)! + la[1] * (n-2)! + la[2] * (n-3)! +.....you can see that la[i] < n — i similarly you can calculate the array lb[i] for the permutation b[0...n-1] now sum these two to get lc[i] = la[i] + lb[i] now at some index lc[i] can be greater than n — i, you can avoid this by shifting the carry to the index i — 1 and reconstruct the array c.

Getting permutation C from the lc array.
This part should be pretty easy. Go from left to right. Let us consider the situation in the beginning. At index 0, our value lc[0] denotes that precisely lc[0] numbers are less than our number at current index. So we can directly say that current number will be lc[0] + 1. So if we go to next index, we need to remember this assignment done at index 0. For that we can maintain a set of remaining numbers in permutation of size n. Now we need to find lc[i]^th the number in this set. This way we can extend the approach for any index i > 0.

We can use BIT for maintaining the required set.

Note: By set, I mean a mathematical notation of set, Don't confuse it with set in STL.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Расскажите, пожалуйста про 23 тест в Div1/C. Очень интересно. З.Ы. много решений упало на этом тесте.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What was the approach for Div 1 D?

»
12 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

What was the approach for Div 1 D?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

Wow, dreamoon_love_AA back to red in no time. Congrats!

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Будет разбор задач?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Задачи с легендой про Мишу — это был идеальный контест :)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

Does anyone have properly commented solution to div1 B (it would be nice if codeforces allowed us to sort searches by the "comment concentration" of code)

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In almost all solutions of Div.2 D / Div.1 B I see magical operation x -= x & (-x) on integer x. Maybe someone can tell what is the meaning of it? And by the way, what is the data structure used? Where can I learn more about it? For me it doesn't look exactly like a segment tree.

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

What are the detailed aproaches to all questions by the writer?

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

Why no congratulations on the winners like in other rounds? :(

»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Codechef is busy doing Hackercup, I guess. :P Server is down.