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

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

Всем привет!

Завтрашний раунд пройдёт на наборе задач Московской олимпиады школьников по программированию для 6-9 классов. Пусть вас не смущает возраст участников, московская методическая комиссия постаралась отобрать для олимпиады разнообразные и интересные задачи. Непосредственной разработкой задач занимались feldsherov, ch_egor, halin.george, ipavlov и GlebsHP.

Надеемся увидеть вас завтра в таблице результатов!

P.S. Будет использована стандартная разбалловка.

UPD Поздравляем победителей раунда!

  1. Mr.Stream

  2. mamka

  3. funtik

  4. HE_MATEMATIK

  5. HollowAngel

UPD2 А вот и разбор задач.

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

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

Auto comment: topic has been translated by GlebsHP (original revision, translated revision, compare)

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

programming competition for school students of grades from 6 to 9.
I was playing Mario when I was in the sixth grade
God bless my childhood

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

Why is my 3rd hacking attempt still waiting while my 5th attempt has been judged?

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

Can you change the contest time, please? .. In Egypt we have a weekly prayer time in that time, an hour after that will be perfect.

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

    The contest time is bounded by the time of onsite competition. It should start after the onsite competition has started and finish before it has finished. I'm sorry, but there is no way we can change the competition time.

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

I hope to change the time as it time of prayer in most of arabic countries

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

This is the worst timing you can put for arabic muslims :D

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

number of problems ?

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

Seems like the King got resurrected .

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

change the time please. it's our week pray time .

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

will the contest be rated???????

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

These days number of problems <= number of problem setters. Get prepared to read long problem statements and strong pretests. I wish I perform well :)

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

It seems like I am the ONLY arab who will participate in this contest

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

Canada I am coming.

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

you will notice a decrease of contestants because of the Arabian issue

hope to change the time of the contest

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

    Please, keep in mind that Codeforces always tries to vary competitions time to give more people an opportunity to participate in at least some of the contests.

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

      Exactly. As much as the typical time may work well for arabs, russians and other europeans, the contest usually ends at 2-5am in Korea, Japan, etc. This is a global community and any time chosen would not work for some people. Also it is well explained above why this time cannot be changed as it has to work around the on-site competition.

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

    But when most of competitions carry out in night time for east regions, it's ok for you and you don't have any problems. Think about others sometimes.

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

This happens when you don't thank MikeMirzayanov, warning! :P

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

To all the people who have pray time during the contest: which one is more important, Codeforces or praying in the name of some god who might or might not exist? I personally think that skipping one day of prayer is justified ;), this can be a secret between you and me, nobody else has to know.

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

Thank God I don't believe in God.

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

Since the king is back, I hope this round will go smoothly :)

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

I don't like long problem statement , please try to keep it short like atcoder!

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

How many to problemset?

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

Can you change the contest time, please? An hour after that will be perfect.

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

Is this round will be rated?

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

Will CF beat the tortoise today?

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

Will CF beat the tortoise today?

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

Rating prediction for this contest could be found here (after contest begins)

Extensions:

About CF-Predictor

Good luck & high rating for everyone!

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

I hope the round will be interesting.Good luck to all participants!

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

points distribution?

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

why scoring is not updated yet?

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

How to solve D?

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

Best Div2 Round ever?

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

I think B is harder than D ...

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

My first comment....Please Upvote me

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

How to solve E?

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

My exact same solution gave me AC in c++ whereas it was giving me TLE in python. This wasted my 15 mins and also 1 incorrect submission

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

My correct output is weirdly getting wrong answer on 1st test case itself -_-

Looks like CF knows dark magic to make correct output wrong.

Is D to be solved with trie? I constructed the trie from nth element to first.

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

Why WA in pretest 1 in D? all samples matched... :/

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

Задача E : Почему мой алгоритм неправильно?

sort honoi by outcome radius non-increasing order.

dp[i] — maximum sum of heights when must use i-th honoi (after sorting) and some j<i honoises.

//there I use segment tree. dp[i] = h[i] + maximum( d[j], 0 <= j < i, and a[j] < b[i] ).

ans = maximum(dp[i], i = 0..n-1);

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

First div 3 round :)

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

i tried to hack a solution using generator but it was showing some return 3 error from validator.exe
Here is the program ,what is wrong in it

generator code

what is wrong with it???

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

When you spend all your time solving C and then realize that D was easier(atleast for me) and should have tried that.

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

How do you solve C without using bitsets? They make the total complexity of my submission O(k*m/64), and that probably won't pass in 1 second ;( upd: yep, it did not

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

Is it okay to ask some questions here? I have joined the contest now and also yesterday but I was unable to submit atleast one solution. I wonder why my rating didn't go down yesterday. Will my rating go down now?

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

KAN please look into what's weird with D? Correct solutions are getting wrong answer!

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

What was the 4th pretest of E about?

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

When you about to click submit button for D and the contest ends. Hope my solution was wrong.

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

With some Arabs praying and some other people sleeping or working Codeforces was deliciously responsive today! Thanks!

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

The test should be at most 256 kb .

Then how can i hack o(n*m*k) solutions at C or o(n*l) solutions at D?

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

Looks like the Div.2 rank.1's solution was written by multiple people.

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

Очень хороший раунд, задачки на логику.

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

My request to feldsherov, ch_egor, halin.george, ipavlov, GlebsHP and KAN

Please look into D. Something's wrong with CF server!

Here's proof

http://mirror.codeforces.com/contest/777/submission/24975275

http://ideone.com/Mxgyyt -> exactly same node, not even a character has been changed. You can compare diff if you want.

Results are so different!

I don't want to lose points because server's fault. Please look into it!

Thanks!

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

Anyone else solved E with sorting and a stack? I can explain my solution if there is interest.

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

    Really? How? I used segment tree + heap, but I'm pretty sure BIT can be used instead of segment tree.

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

      Well, here's a description of my solution:

      First, you sort the disks in a descending order, prioritizing the variables in the order b, a, h. (Note: my code actually swaps the names of a and b) Then, you go through the disks in the sorted order. You remove as many disks as you need to from the stack, until you can place the currently processed disk on top. You maintain the current total height of the stack, and also a maximum achieved height. The maximum height is the answer.

      I couldn't come up with a proof for this, but neither could I come up with any counter-example, and it surpassed all the tests. It just felt like it could work.

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

        I also have no idea why that works :)

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

        I was 30 minutes late to the round. I solved from a fake id. I did this way :)
        This is not cheating :P I didn't submit from multiple id's :P

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

        I am sorting according to outer radius (bigger outer radius first).If outer radius is equal ,then sort by inner radius (again bigger inner radius first ) . Now let's say I have kept two data in my stack for every element (the inner radius and the height) . I maintain a global height variable 'gh'. What I do in every step is that I pop the stack elements till I get the top of stack element whose inner radius is lesser than the current element's outer radius.And then I come out of the loop and push the current element on the stack. In every push and pop operation I update the global height variable gh. And in every iteration of loop I update the final answer.

        Why this would work ? Everytime one pops an element whose inner radius is greater or equal to the current element's outer radius , it's guaranteed that the popped element can't be used in the future as we have already sorted by outer radius so the element's coming later on also won't fit on top of this ring.

        Complexity : NlogN for sorting and N for the main loop with stack operations.

        My solution

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

    same here :)

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

Этот раунд самый удачный — 777

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

The first time I have solved 4 problems.

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

My skill is like Petr's or tourist's when they were in 6th grade.

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

A: AC

B: FST (WA)

C: FST (TLE)

What happened to my brain?

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

How to solve E with segment tree?

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

    Compress the inner and outer radiuses so that all radiuses are less than 200000.

    Sort all the rings by outer radius in the decreasing order. In the case of a tie, sort them by the inner radius, also in the decreasing order.

    For each ring, calculate the maximum height of a tower with that ring on top. This is obviously the height of the ring + maximum height of towers where the top ring has inner radius less than the outer radius of the current ring. Solution with segment tree becomes obvious now.

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

I am shocked by the programs of THE RK1. I don't think a people will code in more than FOUR different code styles. I don't mean he has cheated,just curious.

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

I know a little about the rank 1[user:Mr.Stream] but I know he is about 60 years old. What an unbelievable achievement!!! Could i make friends with you? Thx!

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

I'm too stupid.I use memset and strlen() in the for loop.And I got TLE in C and D

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

Contest was easier than usual, D was little easier than C.

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

About the Rank 1...

There was a legendary man called HangZhou Blade Master...

and now you see that...

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

Actually i can't why My E Programme TLE ON 13..... And i want to say congratulation to rk1[Mr.stream]

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

D is the worst question, why is it D, I think A is harder than D, liked solving C. Why is it like that.

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

A shoutout to all those who stumbled at pretest #4 in problem E cuz of the sort :D

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

When can we see the solutions?

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

Could anyone please tell me why my solution on E got a Wrong Answer on test 39? I tried to solve it by using set and multiset instead of a segment tree,but it failed. Is it possible to solve E this way?Thank you! Here is my solution : http://mirror.codeforces.com/contest/777/submission/24972634

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

    I came up with a group of input to prove my code incorrect. And I found the elements I intended to put into the set actually failed to be inserted. Can anybody tell me why?

    Here is the data:

    5

    2 3 1

    2 4 1

    2 5 1

    2 8 1

    1 2 1

    The expected answer is 4,but I got the incorrect answer 5.

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

Some interesting bug I discover. So my submission 24970450 got wrong answer on pretest one. But when I run it on custom invocation, I got the same answer.

#b

#big

#big

Whereas the output from the judge is

#b??

#big

#big

I know the error comes from my failure in resizing the string, but shouldn't the custom invocation gives the same output as the judge?

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

Is it possible to use fenwick tree instead of segment tree for problem E? I'm got AC with segment tree but WA with fenwick. However, I've used fenwick on prefix RMQ problems before (i.e. when we query for prefixes only) and they've all passed. So now I'm wondering if it's possible or not?

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

Can anyone explain me the complexity analysis of my solution to problem C. Submission Link

My approach was to store all the increasing sequences in in each column ans push the starting and ending points int the map, along with size of sequences and the column in which it occurs. I also store the length of increasing sequences in "pts" vector. This vector is then sorted and duplicates removed from it. Now, for a given query, I simply iterate for all possible length >= (r-l+1) and check if I can get an answer from it. For a given "j", the answer exists only when the pre-computed range covers the entire length. This can be broken down into 3 cases (Similar to linear inequalities). If answer is found at any point of time, I stop the process else I brute force for all possible values of "j" and all possible positions in the matrix.

I think this solution of mine can give TLE on some cases where number of answers "NO" is very large. But even I was not able to come up with a test case where my solution fails. (I have tried this technique in few questions earlier too, but never failed). But still can anyone help me in analysing the complexity of my solution. ?

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

    Yeah, This does seem like it should have TLE'd. Since your query answering time can possibly be linear. So your complexity should be n*m*Log(n*m) + n*m*k

    Former is for the preprocessing on finding non decreasing sequences, while latter is for query answering. As for each of the K queries, in the worse case you might have to iterate through all of the n*m (max possible number of sequences) to find your answer.

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

      Now, I feel the complexity analysis can go as follows. The are sqrt distinct values below given N. So, in most cases, it perform query in O(sqrt(n)). But there is one particular case where it will TLE. The case is as follows. All the columns should be strictly decreasing. So cnt in this case is 1 everywhere. Now, if each query is (n, n), then k in my case will be 1 and I will have to iterate through each of the (n-1)*m grid points to tell the solution.

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

There has been some time since a saw sneaky pretests like these. They were all really light weighted and I forgot how painful it's to discover it after the contest is over.

Yesterday I was Specialist, today I'm sad.

=(

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

What's about announcing the winners of the contest?

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

Waiting for the editorial! Someone please tell me how to do problem C??

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

    My solution solves the queries offline.

    For each row x find the minimum row i, such that the interval [i..x] on some coloumn is non-decreasing.Then iterate through all the queries which end in x and if i < q[x].l , then the answer for the query q[x].order is "Yes" , else it's "No".Thus the complexity is O(n * m + k).

    Check my code for better understanding.

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

About problem E. Many people thought why greedy solution works. The answer is simple: tests are weak.

I wrote my greedy by sorting on bi in non increasing order and ai in non decreasing and failed pretest 4. Then I changed the order on ai to be non increasing too and it passed. I was angry that I did not notice that during the contest. Here is the submission: http://mirror.codeforces.com/contest/777/submission/24979922

I did not notice that property, as it does not work. Here is the counter example, where sorting by ai in non decreasing order gives a better result:

2
2 2 3
1 2 3

The answer is 6, but my program returns 3. It is a pity that these tests were so weak and so many incorrect solutions to the hardest task were accepted.

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

А разбор будет?

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

My solution for problem E gave WA, but I can not understand what I did wrong. Here is my approach:

  1. Sort the rings with respect to 'b' in descending order.

  2. Now consider the rings in the sorted order.

  3. For the ith ring, get the maximum height achieved by i-1 rings with 'a' less than 'b' of the ith ring (used coordinate compression and segment tree for this).

  4. Add the above height to the height of the ith ring and store this value for the ith ring.

  5. Maximum achieved height by all rings after all of them have been processed is the answer.

Link to the solution : http://mirror.codeforces.com/contest/777/submission/24974400

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

Разбор этих задач вообще будет?

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

Nice problemset good work man!!

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

UPDATE: Sorry...wrong thread...it should be under round 402

http://mirror.codeforces.com/blog/entry/50658?#comment-346176