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

Автор Golovanov399, 6 лет назад, перевод, По-русски

Приносим извинения за некоторые проблемы в задачах

Problem A of tc/div2 (В поисках Саске)
Problem B of tc/div2 (Новая техника)
Problem C of tc/C div2/A div1 (Простота исполнения)
Problem D of tc/D div2/B div1 (Сюрикены)
Problem E of tc/E div2/C div1 (Oracle соло мид)
Problem F of tc/D div1 (Дороги и рамен)
Problem E of div1 (Выпуклая игра)
  • Проголосовать: нравится
  • +146
  • Проголосовать: не нравится

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

almost got the idea of DIV2 C :(

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

div2 D was way easier than div2 C !! anyways great contest indeed !!

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

    Can't agree with this. I solved Div2 C in less than 15 minutes, and couldn't solve Div2 D at all. IMHO, the second part of solution in editorial is more difficult than it could be, because after sorting the pair array, we can simply use two pointer method

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

I think proof of Div1 D looks incomplete. You should also consider a case when diameter and optimal path intersect, I think they are a bit different.

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

    Please mark your comment with spoilers. Some participants might want to upsolve without spoilers.

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

    Yeah, little bit.

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

    Correct me if I'm wrong, but I think it still holds when $$$C = D$$$ (optimal path intersects diameter) and when $$$D = F$$$ (optimal path begins somewhere on diameter), so that should cover all the cases. The proof does not make assumptions on edges existing between nodes in the diagram, so setting paths have zero length should be fine.

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

    I'm guessing most people figured out the proof for that case by themselves, but I'll share mine for the sake of completeness (sorry for necroposting lol)

    Firstly, define $$$p(U, V)$$$ to be $$$1$$$ if the parity of the number of stone roads on the path from $$$U$$$ to $$$V$$$ is odd, and $$$0$$$ otherwise. Also, define $$$|UV|$$$ as the length of the path from $$$U$$$ to $$$V$$$.

    Once again, suppose that $$$AB$$$ is a diameter of the tree, and $$$EF$$$ is a maximum-length path with an even number of stone roads.

    Let's first show that $$$p(A, F) \neq p(E, B)$$$. There's two cases, depending on $$$p(C, D)$$$.

    Case 1: $$$p(C, D) = 0$$$

    Since $$$p(A, B) = 1$$$, it must be true that $$$p(A, C) \neq p(D, B)$$$. Since $$$p(E, F) = 0$$$, it must be true that $$$p(E, C) = p(D, F)$$$. The condition holds.

    Case 2: $$$p(C, D) = 1$$$

    The same thing happens, but the equality and inequality flip places. $$$p(A, C) = p(D, B)$$$ and $$$p(E, C) \neq p(D, F)$$$. In this case, the condition holds as well.

    Without loss of generality, suppose that $$$p(A, F) = 0$$$. It must be true that $$$|EB| \leq |AB|$$$, since the latter is a diameter. Hence $$$|EC| \leq |AC|$$$ and thus $$$|EF| \leq |AF|$$$. Once again, we've constructed a valid path which is at least as good, and has an endpoint at either $$$A$$$ or $$$B$$$. This is a contradiction.

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

Golovanov399 why my sol for div2 D getting tle https://mirror.codeforces.com/contest/1435/submission/96683823 please help...

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

Is tourist's submission for problem E somehow rejudged?

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

There's O(n) solution for div2 D using stack. See my code.

But it's hard to explain for me..

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

Did anyone solve D2C with DP? Is it even possible?

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

Was able to solve B today but not A :|

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

Div2C : Each note can be played on a specific range of frets. So out of all such ranges, find the minimum end point (at least one note cannot be played using a higher numbered fret) and the maximum start point (at least one note cannot be played using a lower numbered fret) and output max(0, max_start — min_end). Can anyone point what is wrong with this approach and provide a simple counter test?

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

can someone tell my why I am getting tle https://mirror.codeforces.com/contest/1435/submission/96685352 in problem D.

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

Problem D2C/D1A has a DP tag in it. I would really like someone to help me with the DP solution for D2C/D1A if it is possible. Thanks in advance !

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

i got TLE with N*M complexity on B, helllooo? what's wrong with this " https://mirror.codeforces.com/contest/1435/submission/96705114 " ??? i got accepted with " https://mirror.codeforces.com/contest/1435/submission/96705022 "

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

Super easy solutions and implementation for problems Div2 D and Div2 E: Div2 D: 96705496 Div2 E: 96705529

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

In problem Div2D, if we are getting queries of form "— num", we are updating the lower bound , what we need to do when we get query of type "+" ? I didn't understand this line from editorial "and remove any one of them, because we cannot remove any other shuriken"

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

Question D div2 can be solved in O (n) rather than O(n*log(n))with simple stack and easier implementation, here is an ac solution. https://mirror.codeforces.com/contest/1435/submission/96693538

(Only the solve1() function is the code for this qn)

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

4 + - 1 + + - 4 + - 2 - 3

I have hacked my own solution for Div 1 B/Div 2 D with the above test case. My submission:- 96706130 Systems tests are so weak Golovanov399 amethyst0 Endagorion AndreySergunin

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

Div2 D O(n) solution explanation: note that

  1. if we have several consecutive -x, they must be in an ascending order (otherwise we say NO and stop instantly)
  2. if we have + and a -x after it, we can collapse them (it's not hard to understand that if the answer is YES, we can act this way, just a simple mindfulness exercise)

Bingo! We've just solved this problem in O(n) using stack (going in the reversed order, putting goods on a stack and then taking them from the top of the stack and putting on the showcase). The only tricky moment left: you must pay attention to the amount of shurikens to avoid the lack of them (e.g. example 2 from the problem).

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

Someone please tell where I went wrong 96696335

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

Can anyone tell me why my submission for Perform Easily failed pretest 9 : 96698325 ?

My logic :

The maximal and minimal frets are obviously useful frets i.e. they are used by some fret. So I first sorted the notes and then fixed the "minimal used fret" by using the frets required by the first note by the various strings (the logic being that the smallest note will use the smallest fret from all possible combinations). So out of the 6 frets usable by the first note, one of them should be the "minimal" fret of the optimum set. Then I just binary search for the right hand side by checking if all notes can be played for the specified minimal fret.

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

Div1 D can be solved via top trees without analyzing the problem.

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

How to solve Div 2D using priority queue ?? I don't understand this line from editorial. Otherwise, for all shurikens that had a lower bound of something less than x we increase it to x, and remove any one of them, why do we have to remove any one of them when we exactly know which one to remove , how to handle the other type of operation "+" type .

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

    You can check this solution 96682108

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

    We can iterate an array in a reverse order. (Example 1)

    +
    +
    - 2
    +
    - 3
    +
    - 1
    - 4
    

    we can create an array like this [-1,-1,2,-1,3,-1,1,4] where -1 indicates that the element was inserted(+ sign). Now maintain a min-heap. Iterate backward on this array, we will keep on inserting the elements. We will first insert 4 and 1. Now whenever we land on -1, it means at this point, some shuriken must have been added on the showcase) which can only be either 4 or 1(Since they are sold at the last). So, we can safely remove the minimum element from the heap and add it to the answer. If the heap is found empty at -1 or if we find one of the element in the heap is less than the element to be insert then the array is inconsistent. Also, we can check if number of +'s is equal to n. If it is not equal then the answer is "NO". 96748102

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

      Hey, can you elaborate this part we find one of the element in the heap is less than the element to be insert then the array is inconsistent. ?

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

        The element x which is currently being added indicates the element was sold at this moment and the elements in the heap stores the element already sold out. It also means that at this point, the elements which we have on the showcase are x and all the elements in the heap. By what question says, x has to be the minimum as the customers purchases the minimum element on showcase, but in this case, there is some element in our heap which is less than x and the customer have purchased x instead of that minimum element in the heap. So, it is inconsistent.

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

      Thanks for the explanation. Can you please explain how is this safe? we can safely remove the minimum element from the heap and add it to the answer

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

Здравствуйте друзья ! Я люблю Россию и люблю водку. Рад знакомству. до свидания

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

Why my submission link1 getting TLE but when i changed vector size to (n*m + 5) it get accepted link2 ?

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

    This is a common mistake when there are multiple testcases. It may take 500*500*t if you create/initialize 500*500 arrays every time, and that's about $$$2.5 \times 10^{10}$$$. The statements said that "Sum of $$$nm$$$ over all test cases does not exceed $$$250000$$$" so the second submission could pass.

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

About Problem 2E/1C: I didn't like this problem at all. It was boring and a detail-finding kind of problem where you know right after reading the problem that you can get to the solution if you are not lazy enough.

about the $$$-1$$$ part, we can just see that since $$$a \gt bc$$$, for each spell, whether complete or not, contributes positively to the damage. Hence the damage can be arbitrarily large. No need to think about overlapping parts, as is done in the editorial.

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

Linear time solution of div1B:

Consider the queries backwards. Then — x actually means adding shuriken with value x to the showcase, and + means deleting some shuriken. So we can maintain the sorted stack of all shurikens at the moment. On + we will delete the minimum from the stack (it's easy to see that it's always the best option), i.e. top element, and add it to the answer array. On — x we will check that x is less then the value on top of the stack and add it. If we successfully looked through all the queries we will just print the reversed answer array, and otherwise there's no answer. My code 96667703

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

    I had a similar idea , which unfortunately didn't work. can you please explain what's the flaw with with the following logic.

    Initialise cnt to zero . While processing the queries backwards , if we see + we increment the cnt variable by 1. When we see — x , we push x in the stack if x is less than top element otherwise we can pop atmost cnt number of elements from top of the stack such that now either the stack is empty or top of stack is greater than x.while popping from the stack we decrease the cnt by 1.

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

There is something I can not understand in the proof of 1D.

Tutorial says "Let AB be a diameter of the tree, and the optimal answer be EF." But it seems that in the given tree, AB is not a diameter.

Did I understand what the tutorial wanted to express wrongly? Could anyone explain it for me? Thank you in advance!

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

can someone explain to me whats wrong with my algorithm 96738918 in D2C? i know my idea is wrong,but im confused whats wrong with it

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

Can someone explain A?

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

    If have any query..please ask.

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

Can someone please tell me why my solution is wrong for Div2. A... 96650687

I printed all 1's if the sum of all elements of original array is 0 and I got wrong answer on 10th Test.

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

Could anyone recommend similar problems to div2C&|D?

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

How to approach the problem E with ternary search( Proof of maximal value being a convex function) ??

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

Was div.2-D a standard problem? Everybody is saying that the problem is very easy but I could not come up with a simple idea for the problem. I was thinking of a heavy implementation solution.

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

I think there's also a O(n) solution for Div2 D using list and it's easier to explain.

We consider matching the '-' operations with '+' operations from "- 1" to "- n".

After we matched a '+' operation and a '-' operation, we remove them from the operation sequence.

So, when considering the operation "- x":

If the previous operation is "-", it's impossible to meet the requirements because we have already removed all the numerically smaller "-" operations.

Otherwise the previous operation is "+" and we can easily match this "-" operation with it.

This can be maintained with a list by recording the position of each "-" operation in the operation sequence.

My code

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

All problems(DIV2) are good and do not need a hard data structure. some observation and you can solve.

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

Div2 D can be solved going through the reversed query with a set. Every time we meet a "+" we can just say that the woman takes the one with the least price back. So if set's size is 0 the answer is NO. Else erase that element and add to the answer. Else if we meet a "- x" then x must be the less then the least element in the set now. If not, the answer is NO. If yes, insert x. 40 lines of code.

p.s. reverse the answer in the end

96676641

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

Can anyone tell me why am i getting TLE in div2B? An n^2 solution should have been fine ,right? 96669009

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

I don't know why I TLE in B :(( somebody help me, please!!!!!!! MY SUBMISSION

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

https://mirror.codeforces.com/contest/1435/submission/96662042 can someone tell me what I am wrong?? I can't find anything wrong with my code. please...

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

How to solve div2E with binary search?

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

How could anyone in A saw the row of array like: -a2, a1, -a4, a3, ..., -an, an-1. I mean, no advices on that path weren't given, is anyone sorted out how this works?

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

You can solve KOIREP from SPOJ if you have solved Div 2C/1A

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

Could someone please explain the solution of the div1E?I'm totally confused with the conclusion “the outcome of the game is defined by the index of the last move and the last difference between the elements”and“ if we fix the last index and gradually decrease the last difference, the grundy value will not decrease. ”

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

Why we used set<pair<int,pair<int,int>>> in div2C why can't we just keep track of the value(0-5) in an array of n

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

Could anyone please tell me some other solutions (except two pointers) of the problem Perform Easily? There are so many problem tags for this problem, so I guess there will be some interesting solutions (such as binary search).

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

    I thought of a different approach and used lower bounds and upper bounds but it is failing at test case 9 can you tell me whats wrong with my code? you can go through this I posted this earlier Can Someone tell me why I my code fails at test case 9 96809688 I have used the approach that after sorting the notes the there cannot be a fret smaller than difference between first note and first string then I took two case 1. I found all the frets for every note which is just smaller or equal to the smallest fret. 2. I found all the frets for every note which is just larger or equal to the smallest fret. then I found the Min of differences obtained from these two.

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

      Sorry, I don't understand your approach. However, there is a set of small data that your code can't get the right answer, maybe you can try to discover your mistakes through it.

      Input

      1 1 1 96 99 100

      3

      101 146 175

      Output

      50

      Your answer

      74

      Good luck!

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

5 minutes left time to be ready : )

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

Great Round!

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

Thx for this round!

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

gue mau makan

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

thanks for the editorial!