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

Автор 300iq, 6 лет назад, перевод, По-русски
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
Tutorial is loading...
  • Проголосовать: нравится
  • +116
  • Проголосовать: не нравится

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

Edit: Nvm, it's showing up now

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

How does the interactor work for F?

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

Div2 C can be solved with binary search for the answer. 97454890

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

    Sir, can you please tell me how did got to the solution of A? I just couldnt solve it after spending 2 hrs on it

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

      Well, this is how I thought: -the easiest way for gcd not to be one — to take even numbers only, so gcd of any two to them is at least 2. -Okey, now it is necessary that there are no pairs of numbers that one is divisible by another. And again the easiest way to do so is to make ratio of any two less than 2. So we would have no such pairs for sure.

      With two observations above I immediately got to the solution.

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

    Can you please explain your logic too!

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

      In C?

      First, let's say we are given some time x. How can we determine whether it's possible to get all the food in no more than x?

      Let's go throw the a array. If a[i] > x then we need to go to take this item on our own. Summarise all such a[i]. If sum <= x, then it's ok, we can do this. Otherwise, it's not possible to do this in x.

      Now we can use binary search on answer. (read about it in internet). We can do this since for some first x-s we can't do this in no more than x and starting from some x, which we want to find, we can. So in fact just need to find the first x such that we can do that in no more than x. And to find it we use the binary search.

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

        can you see my code for C ? 103697796

        i can neither understand the editorial nor your explanation.

        what i did was , i would add up the time of the user if and only if that resulting sum after going to restaurant is less than the max(delivery) time.

        But my solution is failing the 2nd test case itself ?

        #define f(n) for(int i=0;i<n;i++)
        
        typedef long long ll;
        
        void solve()
        {	
           int n;
           cin>>n;
        
           vi v(n); //vector<int>
           f(n)
           {
           	cin>>v[i];
           }
        
           vi k(n);
        
           f(n)
           {
           	cin>>k[i];
           }
           
           ll s1=0,s2=0;
           
        if(k[0]<v[0])
           {
           	s1+=k[0];
           }
           
        else
           {
           	s2=v[0];
           }
           
           ll sum;
           
        
        
        
        for(int i=1;i<n;i++)
           {
           	sum=s1+k[i];
           	if(sum < max(s2,ll(v[i])))
           	{	
           		s1+=k[i];
           		
           		
           	}
           	else
           	{
           		if(v[i]>s2)
           		{
           			s2=v[i];
           		}
           	}
           }
        //   cout<<s1<<s2;
           cout<<max(s1,s2)<<'\n';
        	
        }
        
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +70 Проголосовать: не нравится

Straightforward dp solution, where s(i,j) – max possible sum after j operations on first i arrays and transition in O(k), has complexity of O(nk2) or precisely O(k⋅min(nk,∑i=1nti)) and doesn't fit into the time limit.

Or does it?

97479244

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

Can someone please tell me in whats wrong with my this solution for Div2D ? Submission

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

In 1443D-Extreme Subtraction, my idea was to maintain two other arrays which will store the minimum element to the left of element in array and minimum element to the right of element in array respectively for each element in the array. This way I could check for all elements if they are less than or equal to the sum of left minimum element and right minimum element and if there is an element which is greater than this sum then for sure we can not reduce that element to zero. I passed the given test case but failed pretest 2. I'm attaching the code below please help if you can in letting me know where exactly I went wrong. Here is the code 97483817

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

Div2B is simple. I wonder why I wasted my time to come up with a dp solution :))

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

I want to cry out loud, got almost all things in problem C except the case when you have to bring all the parcel on your own!!! I feel it happened because I stressed out in the last, won't do that from next time. AC https://codeforces.me/contest/1443/submission/97496785

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

What does engine editorial mean?

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

Div2D/Div1A tagged dp and greedy. Anyone please explain dp solution.

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

In Div-2 D,

The problem sounds like this — check that there are increasing and decreasing arrays, the element-wise sum of which is equal to the given array.

Can someone elaborate on what this means and how it relates ?

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

Very short $$$O(n)$$$ solution for div2F/div1B 97497692, but I'm not fully clear about why it works.

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

For 1443A — Kids Seating, If there are 3 kids, can't we print "202 204 206" as answer? I get this when i submit the code "wrong answer Integer element [index=1] equals to 202, violates the range [1, 8] (test case 1)"

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

Can someone give an explanation for div2D solution? I can't really understand what is written in the editorial.

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

Немного оффтоп: в статье Смита есть такая иллюстрация image host

Правда же, что $$$G(V_5)$$$ должно быть 1? Игра $$$V_5 + 1$$$ проигрышная.

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

Why this code is getting different verdicts for the same code in C++17(64) and C++17 ?

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

11 6 7 10 9 9 8 ,can anybody explain why and how it is yes

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

This may be a dumb question but how is the answer for sample 3 in div2D NO?

Is the following not a possible sequence of performing operations?

[1 3 1 3 1] -> [0 2 0 3 1] -> [1 2 0 3 1] -> [2 2 0 3 1] -> [1 1 0 3 1] -> [0 0 0 3 1] -> [0 0 0 2 0] -> ... (and similarly for the 2 0 in the suffix)

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

Made the silliest mistake of my life in Div2D.
if(n==1) cout << arr[0] << endl;
instead of
if(n==1)
cout << "YES" << endl;
:(

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

is it rated?

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

Just to mention, as a full-BFS solution to Div.1 problem C:

Let $$$base_{0,u}$$$ be the minimum (even) number of required transpositions to reach the vertex $$$u$$$. Similarly let $$$base_{1,u}$$$ be the minimum (odd) number of required transpositions to reach the vertex $$$u$$$.(Note that their difference wouldn't be greater than 1.) We can evaluate $$$base$$$ numbers by a 0-1 BFS algorithm:

Create a graph with a node for each of the $$$base$$$ array cells;

  • Connect $$$(i, u)$$$ to $$$(1 - i, u)$$$ with a 1 weighted edge.
  • For each u->v edge in the original graph, connect $$$(0, u)$$$ to $$$(0, v)$$$ with a $$$0$$$ edge.
  • For each u->v edge in the original graph, connect $$$(1, v)$$$ to $$$(1, u)$$$ with a $$$0$$$ edge.

Now declare $$$dis_{u, i, j}$$$ as the minimum number of token movements needed to reach $$$u$$$ while $$$base_{i, u} + j$$$ transpositions have been applied and the oddity(# % 2) of the applied transpositions is equal to $$$i$$$(Yes! Half of the states are unused/invalid.). To update $$$dis$$$ values, create a new graph with a node for each triple $$$(u, i, j)$$$.

  • Connect $$$(u, i, j)$$$ to $$$(u,\ !i,\ j + base_{i, u} - base_{1 - i,\ u})$$$ with a $$$0$$$ edge.
  • For each u->v edge in the original graph, connect $$$(u, 0, j)$$$ to $$$(v, 0, j + base_{0, u} - base_{0, v})$$$ with a $$$1$$$ edge.
  • For each u->v edge in the original graph, connect $$$(v, 1, j)$$$ to $$$(u, 1, j + base_{1, v} - base_{1, u})$$$ with a $$$1$$$ edge.

Then run a 0-1 BFS from the $$$(1, 0, 0)$$$ node to evaluate each $$$dis_{u, i, j}$$$.

The answer equals to the minimum value among $$$2^{base_{i, n} + j} + dis_{n, i, j}$$$ with all of the possible $$$i, j$$$ values.

It can be easily proved that it's enough to set the $$$log(m)$$$ as an upper bound for $$$j$$$(third argument of $$$dis$$$) and still solution works correctly. So the size of $$$dis$$$ would be $$$n . 2 . log(m)$$$ and the whole solution would work with $$$O((n + m).log(m))$$$ time complexity.

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

    Is this just for the first part of the problem? What about when you have to do $$$m-1$$$ transpositions? (A line graph with alternating directions on edges.) It seems $$$j$$$ will have to be $$$O(m).$$$

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

      Not actually; Note that $$$j$$$ is the difference between "minimum number of required transpositions to reach $$$u$$$(i.e. $$$base_{i, u}$$$)" and "the actual number of applied transpositions to reach $$$u$$$ in an optimal way", this difference wouldn't exceed $$$log(m)$$$.

      I think in your example $$$base$$$ values would be large enough(almost equal to m or n).

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

Is there any explanation (proof) for 1442B — Identify the Operations for a fact that decisions 1..X-1 (to pick i-1 or i+1) doesn't influence outcome of step X? Basically that it doesn't matter what we did before, step X will always have 0, 1 or 2 options for all possible sequences. I got AC, but wasn't able to prove it.

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

    Here's my thought:

    Suppose that we're currently processing $$$a:=b_i$$$ and let $$$c:=b_j$$$ for some $$$j \gt i$$$. There are two possible cases that previous operations influence our current choice:

    1. $$$a$$$ moves to the border
    2. $$$a$$$ and $$$c$$$ become adjacent.

    The first case is impossible because, before $$$a$$$ moves to the border, the number between $$$a$$$ and the border must be deleted and thus $$$a$$$ is added to $$$b$$$, but numbers in $$$b$$$ are unique, so it's impossible. The proof for the second case is similar.

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

    We need to choose the elements in b[] in given order. So, foreach the coresponding a[i] we can choose the left or right neighbour if it exists. Doing so does not change the number of chooseable neigbours of other elements. Because the removed one is replaced by the choosen one. Because of this the 0, 1 or 2 is invariant.

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

I have an easier solution for Div2F — Div1B: Go through the elements of b, look the position of the current number in b. If there is only one possible neighbour to delete (either on edge of list or one neighbour is a future number in b) take it, if there is no possible neighbour then the answer is 0, and if both are possible you can take either one since the result is in each case the same (the other not taken numbers are equal to the other two possible not taken numbers, each of those numbers can be taken in the future and which two we take doesn't influence the indexes of future takes). You can maintain this with a linked list, nodes have two pointers for neighbours, EZ O(n). Here's my submission: https://codeforces.me/contest/1443/submission/97489269, it's ugly cuz I didnt have much time left, should have made some Node classes instead of just keeping it in an array but thankfully I didn't make any mistake while implementing it (unlike on most tasks in the contest lmao).

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

In problem B, I used memoization. int memo[1e5+1];

I do a memset(memo, -1, sizeof memo); at the beginning of each test case.

There are 10^5 test cases, and i do memset at each one of them. yet my solution was accepted !!?

any explanation?

https://codeforces.me/contest/1443/submission/97508001

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

    It looks like the answer could be weaker test cases — even though the limit is given as 1e5, the max value in the test cases seems to be about 11000. Whilst this would still result in many operations, my understanding is that 1e9 of the very simplest operations is achievable in the time limits. You could try a custom invocation with 1e5 test cases and I suspect it might fail. I’m not certain, though.

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

    Maybe the test data is too weak...

    I even saw that someone use an $$$O(n^2)$$$ algorithm to pass a problem that $$$n\leqslant 10^6$$$. It worked successfully and accepted the problem :)

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

    Your code passes T = 1e5 in 900 ms :)

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

How to solve Div1B — 1442B - Восстановление операций if the resulting array $$$b$$$ is not distinct?

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

I thought I'd share my solution for 1A as I think it's way more interesting than the editorial's solution.

Let's assume the input array $$$a$$$ is the prefix sum array of some array $$$b$$$. Then it's obvious that $$$b_{i} = a_{i}-a_{i-1}$$$ for all $$$i \geq 2$$$ and $$$b_{1} = a_{1}$$$. Now we simply check to see if the absolute value of the sum of negative elements in $$$b$$$ is strictly greater than $$$a_{1}$$$. If it is, the answer is "NO" otherwise "YES"

This boils down to the fact that an operation on the prefix decreases $$$b_{1}$$$ by $$$1$$$ and increases $$$b_{x}$$$ by $$$1$$$ where $$$x$$$ is the length of prefix chosen. An operation on the suffix simply decreases $$$b_{y}$$$ by $$$1$$$ where $$$y$$$ is the length of suffix chosen. Because of the 2nd operation, we can always make the entire array $$$0$$$ if array $$$b$$$ consists of all non-negative numbers. In order to make negative numbers $$$0$$$, we have to "move" a $$$1$$$ from $$$a_{1}$$$ without letting $$$a_{1}$$$ becoming negative itself.

97513072

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

In DIV1C, for the second part, when we know that B > log2(m), I used Dijkstra where distance is a pair where the first part of pair is B and second is A (B and A are same notations used in Editorial). Instead of splitting the graph into two different graphs, I used the number of transpositions till now to decide whether I can traverse the edge or I need to transpose it again. I ensure the minimum value of B, and if B is same, then I checked the value of A. But this approach is getting wrong answer on test 7, and I'm not sure whether there is something wrong with my approach or I can't implement Dijkstra in this way. Please help me understand my mistake. I really appreciate any help you can provide. Link to my submission.

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

    Consider 3 vertices a, b and c. You are currently in a, but you need to reach c, and the only way to do that is through b. To reach b you can either transpose and go to a short path to reach b, or you take a long path to reach b without transposing. But once you reach b you need to transpose to reach c, so it would be better to have transposed earlier (in a) so you could take this shorter path. Thats why you need to duplicate the graph, you cannot transpose lazily.

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

I have a solution that is different from 1443A: You can preprocess the first 100 prime numbers and, when you print the answer, times 2 for each number and that could be fit for the request of the problem :)

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

Why didn't you post analysis for 1441F - Паросочетание

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

I had different solution for problem C. I searched for the minimum number of steps that we should make if we are allowed to make up to $$$T$$$ transpositions. To find such value we can duplicate all nodes, assign cost 1 to regular edges, and cost $$$X$$$ to edges that make transposition. Then, with binary search we can find such values. To avoid several binary search, we can run a single binary search that looks for all values at the same time.

I didn't put too much thought about what was the complexity of this solution during the competition (lucky me). The complexity is $$$O(|V| \cdot \log |E| \cdot |C| \cdot \log |C|)$$$ where $$$|C|$$$ is the total number of distinct target paths that exist. Target paths are those such that a value $$$X$$$ exists where $$$T \cdot X + steps$$$ is minimum among all paths. During the competition I thought this number was bounded by $$$O(n^{\frac{1}{4}})$$$ but it turns out that there are graphs where the number of distinct target paths is $$$O(n^{\frac{1}{2}})$$$.

I managed to hack my solution with one such graph.

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

I was solving div2B, and found this unexpected runtime error in the below piece of code, can anyone explain what's going on?

while debugging, I found that even after prs.size()==0, for loop is getting executed and then giving the error. Pls help.

for(int i=0; i<(prs.size()-1); ++i){
    int diff = (prs[i+1].first - prs[i].second -1);
    if((diff*b)<a){
        cost+=(diff*b);
        segs--;
    }
}

here is the full code for div2B- https://codeforces.me/contest/1443/submission/97530452
I had to use if else to get AC

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

What is the proof for Div1B?

Let's say the answer to the problem is not $$$0$$$. Then how to prove that in the case $$$(3)$$$ while choosing any of the $$$a_{i-1}$$$ or $$$a_{i+1}$$$ will always lead to the solution in the end rather than ending up in a contradiction later on.

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

    First, we can notice, that the actual values are not very important. Let's use | to denote something that we will use later, and . to denote something removable. You should note, that the order of the | chosen is still important, though not represented here.

    So our array looks like ..|...|...|...|...|....

    Now we can see that one of the | will be next. After we add it to the array b, it is useless, and removable like a ., because all values in "b" are distinct. So using either |. and .| in .|. yield a ... So the next state is the same regardless of whether we choose left or right.

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

Can someone Pls suggest some more problems like div2D/div1A.

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

Don't know who needs this counter test case in div 1C but I definitely did, so I'll share it:

9 9
2 1
2 3
9 3
1 4
4 5
5 6
6 7
7 8
8 3

Expected Output: 8

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

I think the test data of Div2D/Div1A is not so strong, here is an accepted $$$O_{(n^2)}$$$ solution.

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

About Div.1 D, I have another solution with complexity O(nklgn),the idea is that some of element will never be choice.Then we calculate the prefix sum and sort the column,for the j-th column the last n-1-k/j element will never be choice. here is code. https://codeforces.me/contest/1442/submission/97548953

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

Someone can explain Div2E task. How we generate a permutation with the corresponding number?

And why only the last 15 elements need change, if there may be such a situation when the last 15 elements are initially in descending order and the 16th element needs to be changed

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

    There are n! permutations of {1,2,3,...,n}. But how do they look in lexicographic order?

    Let's look at first 6 permutations (n >= 3): 1: {1,2,...,n-2,n-1,n}, 2: {1,2,...,n-2,n,n-1}, 3: {1,2,...,n-1,n-2,n}, 4: {1,2,...,n-1,n,n-2}, 5: {1,2,...,n,n-2,n-1}, 6: {1,2,...,n,n-1,n-2}. As you see, only last three elements were changing their positions. Why? Because 3! = 6, so first 3! = 6 permutations only permute last 3 elements. In general, for given 1 <= k <= n first k! permutations of {1,2,...n} only last k elements change their positions, the first n-k elements are always {1,2,...,n-k} in that order.

    "And why only the last 15 elements need change?" - Let's notice that we have x <= 2e5 and q <= 2e5 and we start from X=1 permutation index. Therefore at the end maximum possible index is X <= 1 + 2e5 * 2e5 = 4e10 + 1. Just because 15! > 4e10 + 1, we know that only last 15 elements can change. In fast it is sufficient to look at 14 last elements, as 14! = 87178291200 > 4e10 + 1.

    "How we generate a permutation with the corresponding number?" - We can enumerate all permutations of {1,2,...n} with integer numbers from [1,n!]. An example algorithm of retrieving permutation from its index is explained here: https://www.geeksforgeeks.org/find-the-k-th-permutation-sequence-of-first-n-natural-numbers/. However, this code returns string and assumed an integer index, but in our case it can exceed integer range, remember about it. My code (https://codeforces.me/contest/1443/submission/97579828) uses this approach to retrieve permutation from index, you can look at it.

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

In editorial of problem Div2 D : How to prove that " maximizing each element of the decreasing array" is the best way to construct the increasing and decreasing array and can people tell their train of thought while arriving at above during contest.

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

Please help me to find what I did wrong in my code.

https://ide.codingblocks.com/s/367339

In my Approach, I simply created two partial sum arrays. The first from the beginning called pre and the second from the end call sum.

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

D <= C <= B <= A <= F <= E for div2 -_- A ruined my whole contest!

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

Did anybody solve div2D using segment tree like me :v

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

someone please explain how third statement is correct? According to me array should become [2 1 0 -1 2]

1.decrement from the first two elements of the array. After this operation a=[2,1,2,1,4]; 2.decrement from the last three elements of the array. After this operation a=[3,2,1,0,3]; 3.decrement from the first five elements of the array. After this operation a=[2,1,1,0,3];

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

Can someone tell me how the divide and conquer works in Div1 D?

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

    Basically, we are aiming to solve knapsack problem (precisely, calculate entries of dp array) for $$$n$$$ elements but $$$i$$$-th one for all $$$1 \le i\le n$$$ mentioned in the editorial.

    Here, we will divide $$$n$$$ arrays into two halves ($$$A$$$ and $$$B$$$), and then calculate the dp array $$$dp_l[]$$$ (resp. $$$dp_r[]$$$) if we take the first half (resp. second half) elements into account, i.e. we are free to choose any subset of the first half(resp. second half) elements. With auxiliary array $$$dp_l[]$$$(resp. $$$dp_r[]$$$) in hand, we may only focus on the initial problem for the second half(resp. first half) and merge them in the obvious way.

    btw, you may check others' implementation to get a better understanding. (That's how I understood above approach... I was confused by editorial as well)

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

For problem C, why does Accepted one works while this almost identical one Wrong One gives memory limit exceeded . The only difference between the two solution is that I copied the contents of the loop from the wrong one and pasted it in a function, then called it instead in the loop to solve, and now I don't get memory limit exceeded using the function. Why is this happening ?

Problem C

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

Can anyone please explain me problem D of div 2. I am not getting it

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

I've written a blog post to explain the solution to 1443D (D1A / D2D)

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

Squeezed $$$O(n k \sqrt n)$$$ solution in D1D. With pragmas submission

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

Good evening, this is our solution for problem C with explanation.

Video link

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

In C I used multimap and it was ac,then i used map and for multiple same courier delivery time i kept summation of all the pick up time at the index of that courier delivery time.Rather than this one difference everything else was same.why it isn't working? Example 3 3 5 5 / 2 2 2 2 I kept 4 at index 3 and 4 at index 5.

Here are my submissions: AC:https://codeforces.me/contest/1443/submission/97495754 WA at TC2:https://codeforces.me/contest/1443/submission/98000111

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

Div 1C is just pure genius (the making copies of graph part). Never seen this before. Just....wow.

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

300iq This page is not linked with the contest problem page neither is the announcement page .. Can you please look into it

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

memory efficient DP approach for problem B: https://codeforces.me/contest/1443/submission/101710030

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

Hi, I didn't want to make a new blog for this, so here I am. Regarding problem D.

Spoiler

Please correct me if you see a mistake. Any help is greatly appreciated.

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

    So, basically, for each i, we have a range of $$$[L,R]$$$. For all ranges of all element, could we choose a number $$$X$$$, such that if we create an array which will stores the value $$$X$$$ for all $$$i$$$, the array could be non-increasing ?

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

In problem D, why is it check that there are increasing and decreasing arrays ? why not check that there are decreasing and then increasing arrays ? Isn't the problem basically boils down to whether we could make the the array decreasing and then increasing ?