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

Автор wilcot, история, 10 лет назад, По-русски

Привет, Codeforces!

Меня зовут Иван Удовин. Хочу сказать, что Codeforces Round #344 будет проведен в этот четверг (3 марта 2016 г. в 19:35). Это наш первый раунд, но это не означает, что задачи будут скучными и неинтересными. Авторы задач: я (wilcot) и Илья Хейфец (ikheifets). Говорим спасибо Алексею Вистяжу (netman) и неизвестному человеку (он не захотел, чтобы его добавляли в анонс). Также я хочу сказать спасибо Федору Коробейникову (Mediocrity) за отличную идею по задаче E.

Мы благодарим Глеба Евстропова (GlebsHP) за его помощь в подготовке соревнования, Марию Белову (Delinur) за перевод условий на английский язык, и, конечно, команду Codeforces и Михаила Мирзаянова за уникальные платформы Codeforces и Polygon.

Раунд будет состоять из пяти задач. Главные герои: Блейк — основатель компании «Blake Technologies» и Крис — работник этой компании.

Разбалловка стандартная: 500, 1000, 1500, 2000, 2500.

Желаю всем удачи на соревновании, высокого рейтинга и побольше задач с Accepted.

PS. Разбор можно просмотреть здесь.

PPS. Поздравляем победителей:

Div. 2:

  1. lovelive

  2. Murtazo.Ali

  3. chychmek

  4. chrome

  5. Batman

Div. 1:

  1. Um_nik

  2. chffy

  3. natsugiri

  4. ershov.stanislav

  5. AndreiNet

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

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

I miss a normal codeforces round. I think this one will be interesting. Good luck to everyone.

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

There is a small typo in the article — while the article says Wednesday, the actual round takes place on Thursday. Could you fix it please?

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

A new round, and an new hope to become expert ^_^

»
10 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится -26 Проголосовать: не нравится
and unknown person (he don’t want to be added in the announcement)

but it is important to know who tested a round for us. Generally, a round won't be interesting if people see it was tested by a newbie, but higher ratings can draw more attentions, right? So, at least writing the tester's rating can be useful here. Alternatives,

Thanks a lot to Alex Vistyazh (netman) and an International Master (who don’t want to be ...

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

nice short announcement. waiting for an interesting problem-set and best of luck for your first round.

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

expert next goal

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

Codeforces Round #344 (Div. 2)

Why do they always add Codeforces before the round? Who doesn't know this much? Or maybe its just a safety measure to stop people from asking questions like Will the round be conducted on Codeforces? In that case, you can change the heading to Rated Codeforces Round #344 (Div. 2)

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

It will be rated?

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

Кто может подсказать как решить задачу, предположительно на декартовы деревья, но непонятна идея http://acmp.ru/index.asp?main=task&id_task=647

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

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

"Main heroes of this round: Blake — the owner of the "Blake Technologies" company, and Chris — an employee of this company, and others." I think there is tree problem :3 , the root of the tree is Blake and Chris is one of the leafs :D . it will be so interesting if that's true :D .

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

No dynamic scoring please -_- Hope to see some interesting problems with good problem statement :D

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

Only in my device Google Chrome didn't open or brake Codeforses(last 30 minute)?

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

I might be the only contestant who got hacked on A. RIP :D

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

Не могу взломать участника потому что макс тест превышает 256кб(

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

Interesting problemset!

Can someone describe me solution for the fifth task ?

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

    All I've came to:

    You need to maximize value sum(A[j], A[j + 1], ..., A[i — 1]) — A[j](i — j) if i > j. Or value A[i] * (j — i) — sum(A[i + 1], A[i + 2], ..., A[j]) if i < j.

    And print initialy characteristic + (diff > 0 ? diff : 0)

    How to do this faster than O(n^2) I can't get:D

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

    We iterate the array. For ith index we will find the best position j, left to the i (it could be right instead of left, but we will compute the right in another iteration), which maximizes (this equals to change of the value of the array when we move jth element to ith position).

    As I said before we do the same thing (almost the same thing, equations are little different of course) for right. Then, the answer is the value of the original array + max(0, max of all changes).

    To find the best j for a particular i, we need to fiddle with the equations a little and represent every element as a linear line:

    ps[0] =  - ar[0]

    ps[i] = ps[i - 1] - ar[i]

    max1 ≤ j < i{ps[i] - ps[j] - ar[j] * j + ar[j] * i} = ps[i] + max1 ≤ j < i{( - ps[j] - ar[j] * j) + ar[j] * i}

    Now we can represent ith element as a linear line. ith line equals to y = ar[i] * x + ( - ps[i] - ar[i] * i).

    We first add the line 1. We then start iterating from index 2. When we're done with i (computed the result for it), we add the line i to our structure.

    (To find the result for that position) When we're at a new position, let's again call it as i, we find the line which has the highest value for x = i. We also need to increase this value by ps[i].

    To find the best line, we can use the convex hull trick on a segment tree, since slopes aren't non-decreasing like in the case of traditional convex hull trick.

    Time complexity: O(NlogN)

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

I swear, in next few CF rounds I will not hack! :(

How to solve C? I guess we have to sort three values i, ti and ri according to ri? How to do the same?

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

    I did it with segment tree+two pointer. Phew! Lot of confusing code

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

      I thought of solving the problem like this. Find maximum value of ri and it's position in input. Then all sortings done before this input will be useless. After this input, check for next largest value of ri and repeat this process. Obviously after finding ri we have to do something in array(I still need to find out more).

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

        I thought along the same lines but this would fail for worst case as in:

        1 10
        2 9
        1 8
        2 7
        1 6
        
        • »
          »
          »
          »
          »
          10 лет назад, скрыть # ^ |
           
          Проголосовать: нравится 0 Проголосовать: не нравится

          Yea i thought of that case too but i think we can do something between finding next ri. Like if we say for t1=1, r1=10 and t2=2, r2=8 then we can say from 1 to 8 array is descending and from n=9 to 10 array is ascending. Now we choose numbers in array. I think it can be done nikitosoleil method(two arrays). I am not sure.

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

      My solution is much more easier. I have two sorted arrays (increasing and decreasing order) and taking a look only at elements, that had changed their position. For every position I store will it be sorted at last time int dec or inc order. In first case I am placing in this position first unused element from dec array, in another case first from inc arr. You can take a look at my submission: 16494098 for better understading me. Hope that this will work. P.S. It was the first time when I have submitted three problems less than in one hour :) UPD: Failed. UPD2: Bugged code, but right idea. Some little changes and AC: 16501782

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

    What I did:

    Found the maximum number of sorted elements from all queries, from 0 to x

    Sorted [0,x]

    Then from that query looped to the end of the queires reversing the array from 0 to query's length, keeping track of what order was used last time. If the order changed, then reversed the array, otherwise did nothing.

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

      I think your solutions fails for this test : in

      I have hacked a similar solution with this test.

      N = 200000
      K = 200000
      print N, K
      for i in xrange(N):
         print i + 1,
      print
      for i in xrange(K):
         if(i % 2 == 0):
            print 1, N — i
         else:
            print 2, N — i
      
    • »
      »
      »
      10 лет назад, скрыть # ^ |
      Rev. 3  
      Проголосовать: нравится 0 Проголосовать: не нравится

      I won't know until system tests are over, but I did the following: EDIT: Failed on test 13. I think the main idea is correct though, so check the last paragraph.

      1. If there are n numbers, create an array of size n (orderings) of integers, initialized at 0.

      2. Read input numbers and put them in a linked list. Create empty stack too.

      3. Read managers. For each manager, set orderings[r] = t (1 or 2).

      4. Set sorted = false. For i = n — 1 until 0:

      4.1. if (ordering[i] != 0 && !sorted) list.sort(), sorted = true;

      4.2. if ordering[i] == 1: pop from the left of the list and push to stack.

      4.3. else: pop from the right and push to stack.

      1. Pop from the stack and print until empty.

      It's not exactly that, because when ordering is 0 you have to look at the last order, unless no sort has been performed yet.

      I'm not sure about whether it's right or left for orderings 1 or 2, because I don't remember which one was nonascending/descending, nor the default order of list.sort(). But when ordering is 0 you always pop from the right (if no sort has been done yet, else you follow the previous left-right rule).

      The idea is that if the largest sort is n — k elements, the last k are in the initial order. From there, the n — k — 1 indexed element is the biggest/smallest number left (depending on the direction of the last sort of that size), the list is reduced in each step this way, until you get to the empty string.

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

    I simply took maximums of type_1 query and type_2 query except for the last query, if in case last query is for type_1 then i first sorted max(type_2) in non-descending order and then sorted max(type_1) in non ascending order,and vice versa for the type_2 query in the last query. hope it works... :)

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

Somebody know why KMP on problem D might give WA14? And how did you solve that problem? I thought of KMP, but now I see that I could use hashing also.

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

Wow C has 1k submissions!! It took me lot of time to code C

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

So, what was the hack cases for A and B?

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

Second problem with O(k*n) k = 100000 n = 5000 failed in hacking. So fast...

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

noticed my solution for B is wrong after locking it , so hacked 10 people :p

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

I wonder what was test 7 for problem D. I really can't figure out what was wrong in my solution... anyway, if A, B, and C all pass, it will still be a good result. :)

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

How to solve C?

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

    Let's assume we have instruction 1-n. Everything before that instruction doesn't matter. So let's find the last instruction 1/2 — n. If that doesn't exist the number stays the same, if it does we have to take the smallest or the largest number in the array. After that we search for 1/2 (n-1) that is after our previous instruction and do the same process, but we also have to remember what was the last instruction that was made(if it was 1 or 2 so we know what number do we have to search for). We can sort the instructions and also use the set to get maximum/minimum and to remove elements(after we have used them already) so the complexity is O( (n+m) (log n + log m))

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

      What if there are consecutive instructions like for n = 10 1 10 2 9 1 8 2 7 1 6 2 5 1 4 2 3 1 2 1 1 this will sort the array 10 times right?

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

        After the first instruction we know, that result[10] is equal to biggest number in array, and it won't change, after the second one we know that result[9] is equal to smallest number in array without the biggest number — so smallest number, after third we know, that result[8] is equal to the biggest number in array without biggest and smallest number etc, you don't need to sort it every time

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

Hmmm I hacked a lot of people with O(M*K) solutions on B. So why do they fail? Shouldn't they run in time? I implemented this solution just because I taught it will pass . . .

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

At first I read OR as XOR in A. Anybody else coded for XOR lol

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

problem A can't hack in n^3

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

Хэши — неистовое зло... Сдал Д за 54 секунды до конца.

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

I hope there will be me many TLE on problem A and B after system testing.

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

So, maybe authors could comment why they picked so tight input limits on problem B? Basically what I don't like about this — brute-force solution wasn't cut.

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

very nice problems and I enjoyed... I understood u love optimizing algorithms a lot :)) tanQ guys :)

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

wanted to act like an expert and went for C first without even looking at A and B. Spent too much time on C and could not submit B :v Looks like my being blue was just a fluke. I am not ready yet :v

And , as a result, today I will go back down to my rightful place. How the heck people solve problem like C in 20 minutes -_- . My brain feels dizzy after 1:15 hours of non-stop storming on C :/

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

I thought 5*10^8 operations can be done in 1 sec :(

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

codeforce i want to say thank you !!!! such a interesting question and help full for improve my coding skills. again thank you.

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

absolutely loved this contest, waiting for the next contest from wilcot and ikheifets

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

Наконец-то chrome будет кандидатом

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

Wow i thought i flunked this contest but rank went from 1.8k to 1.3k. I guess my rating will go down by only few points.

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

It feels bad when you fail something you spent 1:20 hrs on ;_;

Curse of the tourist. Never make fun of tourist ;_;

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

TLE in PyPy (16491742) and AC in Python (16500293) with exact same code. :|

Isn't PyPy supposed to be faster? Also, aren't Python/PyPy time limits supposed to be 5x that of default time limits?

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

Oh :-( Overflow... :-(

http://mirror.codeforces.com/contest/631/submission/16496133 vs http://mirror.codeforces.com/contest/631/submission/16500541

Overflow doesn't allow me to get AC from all of the problems of this contest. :-(

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

When will we see the rating change?

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

Auto comment: topic has been updated by wilcot (previous revision, new revision, compare).

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

Can the Div. 2 D be solved using KMP? My approach was like I would compress multiple characters to single character and form a string. Then I'd use KMP to find the matching between the two. I keep tract of (l, c) pairs. I know their frequency and where they match. With this much information please help me find the answer. My code : http://ideone.com/yb5JCW

Thanks in advance.

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

It was a really nice problemset. Thanks!

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

I think there is a little problem. I solved two problems, you can check it in the standings (465th).

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

10 days without contests?

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

Congratulations..

contest was be very interesting. especially the last question is very interesting :) but I can not solve this in contest )

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

How to sort 2d array according to first column? I know how to do it for 2 columns(using pairs) but how to do it when columns are more than 2?

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

how many operations the codeforces server do in one second? ◉_◉

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

anyone on how to solve c? i sorted queries on basis of ri>rj and implemented sorts while skipping ones with ri<r(i-1)&& i<j. some people solved it with segment tress . please explain it?

thanks_in_advance