Stepavly's blog

By Stepavly, history, 5 years ago, translation, In English

1282A - Temporarily unavailable

Idea: MikeMirzayanov Preparation: MikeMirzayanov

Editorial
Solution (MikeMirzayanov)

1282B1 - K for the Price of One (Easy Version), 1282B2 - K for the Price of One (Hard Version)

Idea: MikeMirzayanov, unreal.eugene Preparation: Supermagzzz

Editorial
Solution (Supermagzzz)

1282C - Petya and Exam

Idea: AdvancerMan Preparation: Supermagzzz

Editorial
Solution (Supermagzzz)

1282D - Enchanted Artifact

Idea: unreal.eugene Preparation: unreal.eugene

Editorial
Solution (Darui99)

1282E - The Cake Is a Lie

Idea: MikeMirzayanov, AdvancerMan Preparation: AdvancerMan

Editorial
Solution (AdvancerMan)
  • Vote: I like it
  • +47
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
Rev. 3   Vote: I like it +4 Vote: I do not like it

Could anyone explain why the problem D answer for the below case is 1?

6 17 2 6

0 0 1 0 0 1

7 6 3 7 10 12

When can the student leave to get 1? If the student leave T=6, he can solve 3th problem, but the 2th problem makes his score 0. Am I missing something?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    Petya could solve one of easy problems and leave exam at time 2.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In this case, you should prioritize easy problem over hard problem, which takes exactly 2 minutes.He can leave immediately when he solve a easy one at t=2.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Actually, it's problem C, not D.

»
5 years ago, # |
  Vote: I like it +5 Vote: I do not like it

Solution to problem B is not very clear yet. Can someone please explain it in little more detail?

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it +10 Vote: I do not like it

    Sort the items by price. Let us say we wanted to buy only all of the first i items by paying the minimum price possible, call this minimum price needed dp[i].

    If i >= k-1 (0 based index).

    We will definitely have to buy the most expensive item but on purchasing that we can get items from i-k+1 to i-1 for free.

    So dp[i] = cost of item i + dp[i-k]. If dp[i] <= budget, our answer is atleast i+1.

    If i < k-1 the case is simpler, check the code for this case.

    Also if there are n items on sale, there is no point of purchasing an expensive item but leaving out a cheaper one. In essence if you buy some ith item you will definitely buy first i-1 items also. Let me know if you'd like a proof for this too.

    https://mirror.codeforces.com/contest/1282/submission/67533829

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thanks , for the explanation. Can you also explain what is said in the editorial,I think it's a little different from this(dp) approach?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +1 Vote: I do not like it

        I feel it's almost the same.

        Not sure though.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +4 Vote: I do not like it

        dp is kinda parallel counting for all possible prefixes, while solution from editorial is serial: try first prefix, then run with step k; try second prefix, then run with step k, and so on.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Wanted to ask that for i=1 to k-1 (in ur case: 0 to k-2), we can't apply the offer bcz. we don't have exactly K items to buy. So, in that case shouldn't it be 1 item(not applying the offer). Your code looks like that we can buy less than K items. Can you clarify if we can buy less than K items or not?

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 2   Vote: I like it +3 Vote: I do not like it

        We can definitely buy a single item without using the offer. If you buy say g items, g < k, then you have to pay sum of individual cost of those items equivalent to buying each of them one at a time without using the offer.

        In my code dp[i] where i < k-1 is simply the prefix sum.

        Let me know if this clears your doubt.

        You have both the option of applying the offer or not applying it.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          can you explain more how offer is used and not used in both the conditions (i >= k-1 and i < k-1 )

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            You may only use the offer if you buy exactly k items. Say K=5, you want to buy 7 items, you can buy 2 items individually without using an offer and 5 items on offer. Not sure what exactly you are trying to ask but still hope it helps.

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      t=1 n=5 p=6 k=2 A=1 2 4 5 7

      for this case if we buy price of 5 we have {5,4,1} as purchased items and the optimal buy would be {4,2,1} ,here both types of purchase are optimal.So how can we be assured of the fact that higher purchase will not lead to best result

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hi kartik8800 could you please elaborate the proof that after sorting if I buy some ith item I will definitely buy first i-1 items also

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it +3 Vote: I do not like it

        Try proving it on the following lines :

        There exists no way to get exactly X items for a cheaper price than the way in which you get the first X items.

        Think of the three cases : cheapest way to buy X items when X < K, X=K and when X >= K.

        Proving for X<K and X=K should be trivial.

        For X>=K you can try proving by contradiction. Assume there exists a way to get exactly X items in which you buy some item j with j > X and then try to contradict this.

        Let me know if you're stuck and I'll give more thought to the formal proof and if you do come up with a proof do share.

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Can you please tell how to prove this fact. I am unable to come up with a proof.

»
5 years ago, # |
  Vote: I like it +16 Vote: I do not like it

My solution for problem E is similar but definitely much shorter, the main idea is to take an arbitrary triangle to remove it and recursively solve on the three sides, I have a list with the order of vertices and other for the order of triangles, in my recursive function I have a fixed side(edge) then I find one arbitrary triangle with that edge and solve similarly for both sides

»
5 years ago, # |
  Vote: I like it +35 Vote: I do not like it

I have another approach for $$$D$$$.

Assume length of $$$s$$$ is $$$l$$$. First, query with $$$t$$$ = "a" and let the response be $$$r$$$. There are 2 cases:
1- string $$$s$$$ consisted only of "b" letters, then $$$l = r$$$.
2- string $$$s$$$ had at least one "a" in it, then $$$l = r + 1$$$.

Now query with $$$t$$$ of length $$$r$$$ consisting only of "b" letters and let the response be $$$e$$$. If $$$e = 0$$$ then terminate, otherwise, You have 2 pieces of information:
1- $$$l = r + 1$$$.
2- The distance between string $$$s$$$ and string full of "b" letters of length $$$l - 1$$$ is $$$e$$$.
3- $$$s$$$ has at least one "a" in it.

Now, let $$$t$$$ be a string of length $$$l$$$ of only "b" letters. The distance between $$$t$$$ and $$$s$$$ is also gonna be $$$e$$$ (I think the only case where this is not true if string $$$s$$$ consists only of "b" letters, which we know it already doesn't. Would love a proof for this tho).

Now just like the rest of the solution in the editorial, iterate over $$$t$$$ from $$$1$$$ to $$$l$$$ and try to turn the character to "a" and query. If the distance in the response is less than $$$e$$$, then update $$$t$$$ and $$$e$$$. keep doing this until the response is $$$0$$$

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For the question, Price of one easy version i tried to solve it using modification of knapsack but it gave tle on pretest 3. Did i miss something, code is as below:-

private static int getMem(int[] a, int n, long w, Map<String, Integer> map) {
    StringBuilder sb = new StringBuilder();
    sb.append(n).append(":").append(w);
    String key = sb.toString();
    if (map.containsKey(key)) return map.get(key);

    if (n <= 0 || w <= 0) {
       map.put(key, 0);
       return 0;
    }
    if (a[n-1] > w) {
       int value = getMem(a,n-1,w, map);
       map.put(key, value);
       return value;
    }
    else {
       int d = Integer.MIN_VALUE;
       if (n-2 >= 0 && a[n-1] <= w) {
         d = 2;
       }
       int val = max(1+getMem(a,n-1,w-a[n-1], map), getMem(a,n-1,w, map), d+getMem(a,n-2,w-a[n-1], map));
       map.put(key, val);
       return val;
    }
}
  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    You can optimize this to linear time, since the values of all of the items are equal. For example, since an item with cost 10 and another with cost 5 are always equal value, you always want to take the one with the smaller cost.

»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

In solution to problem B, the sort function is used which takes o(n*log(n)) time complexity. So how come the solution has linear time complexity? Please explain!

  • »
    »
    5 years ago, # ^ |
    Rev. 3   Vote: I like it 0 Vote: I do not like it

    It is not, but since the $$$a_i$$$s are only from 1 to 10^4, we can use radix sort or counting sort to sort the numbers in $$$O(10^4)$$$ time

    Update : As the number of testcases is large($$$10^4$$$), so it won't probably pass, so nevermind, just use quicksort.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      but the editorialist solution uses builtin quicksort function brother

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        We can do, the solution is not linear though, it indeed is $$$O(nlog n)$$$

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It will take 10^4 iteration per test case,which will give worse time complexity than nlogn.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Not at all, it would give us $$$O(10^4+n)$$$ time which is linear in n

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          It will surely take O(10^4) to sort the array per test case, and total no test case can be max 10^4. so here worse time complexity is O(10^8) which is worse than nlogn.

          • »
            »
            »
            »
            »
            »
            5 years ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            Ahh I see, then it sure is not linear, thanks for correcting :)

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      radix sort is $$$O(n \log(A))$$$ where $$$A$$$ is logarithm of number of possible values. counting sort is $$$O(n)$$$.

      You can do $$$O(n)$$$ here, but I came up only with offline solution. It's useless.

      Here is comparison:

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Someone Please Help me Correct my Solution For Problem B. I am unable to find which case I am missing . It would be of great help. My Solution :- (https://mirror.codeforces.com/contest/1282/submission/67578229)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    PROBLEM B

    Can someone Please Explain this Test Case?

    4 9 2

    2 3 4 5

    How the answer is 4?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You can buy goods worth 4 & 5 for 5 coins and goods worth 2 & 3 for 3 coins.Hence answer is 4

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Is it allowed to do this operation multiple times?

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Yes as long as you have ample amount of money left . You can buy as many items as you want

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          it is written in question**Vasya can perform one of the following operations as many times as necessary**

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Can you please explain again in detail? I didn't get what you said.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      As we can take 2,3 as one pair and 4,5 as another pair so re money is max(2,3)+max(4,5) i.e. is 8 which is less than 9 so we have one unit of money left.. Since we have no other toy this is our final ans;

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      First buy 5 and then you get 4 for free and then buy 3 you get 2 for free so total cost = 8 but you have 9 and so you buy 2 goods and get 2 for free

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Could anyone explain problem B in more detail

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    first sort the prices.let dp[i]= min cost to buy i items.for i<k-1, dp[i] is the prefix sum of prices since we cannot use the offer.else dp[i]=a[i]+dp[i-k] . solution

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

My submission for C giving WA. Someone please help!! Edit:: I think I got my mistake..

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

In problem C, why is the answer of this testcase $$$1$$$ ?

1
6 17 2 6
0 0 1 0 0 1
7 6 3 7 10 12
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For the first problem(temporarily unavailable) in the fifth test case a=-10 b=20 c=-17 r=2 , the coverage will be from [-15,-19].so a to b must added, the answer must be 31, if I'm wrong case someone explain why I'm wrong.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The time taken to travel from a to b is 30 units right? Cause you travel from 0 to 1 in 1 unit time

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Please find the error in my code i don't know what's going wrong here My Submission for Problem D

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For Problem B. first sort all the goods by its price.and take this array as p[]; then let f(x) means the least money he should pay to buy first x goods. so if x <= k , f(x) = f(x-1) + p[x] if x > k , f(x) = min(f(x-1) + p[x],f(x-k) + p[x]) // use offer or not then iterater all the f(x),find the most x satifies f(x) <= the money I have. does I make this problem more complex?

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

problem b order is $$$O(N^2)$$$ ?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I was also confused initially

    But notice you visit every index just once so the order is O(n).

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

can someone explain C approach briefly?

»
5 years ago, # |
  Vote: I like it +1 Vote: I do not like it

In tutorial of problem 1282D - Enchanted Artifact:

Consider an arbitrary string $$$t$$$ of length $$$l$$$ and let the answer to its query be $$$q$$$. Then if we replace the letter $$$t_i$$$ with the opposite one (from a to b or from b to a), then we may have one of two situations:

  • $$$q$$$ decreased by $$$1$$$, then the letter $$$t_i$$$ after the change coincides with the letter $$$s_i$$$.

  • otherwise the letter $$$t_i$$$ before the change matches the letter $$$s_i$$$.

I think that this is not truth. For example:

$$$s=$$$ abababababababababab

$$$t=$$$ babababababababababa

Edit distance is $$$q=2$$$ (delete the first character and insert the last one).

Let's replace some a in the middle with b (the letter $$$t_i$$$ after the change coincides with the letter $$$s_i$$$):

$$$t'=$$$ bababababbbababababa

Edit distance is $$$q'=3$$$ (replace this letter, delete the first character, and insert the last one).

The letter $$$t_i$$$ after the change coincides with the letter $$$s_i$$$, but $$$q$$$ didn't decreased by $$$1$$$.

Am I right?

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +11 Vote: I do not like it

    does the author means the t is all letter 'a' at first.
    so it can't be babababababababababababa it can only be babababababaaaaaaaaaaaaa so convert from a to b will make difference?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Maybe, but he didn't write it.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +8 Vote: I do not like it

        but in his codes, he inits the t in this method. so maybe this is what he actually means.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      BTW, how can this be proved?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it +8 Vote: I do not like it

        I think because the s and t has same length. So the quickest way to transform from t to s is to replace each a to b where the char in them are different. if a change from 'a' to 'b' make the distance greater(we need more step to make make t equal to s cause our change), it means this position should be 'a', otherwise, it should be 'b'.

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it +13 Vote: I do not like it

    You are right. Actually, these statements are not true in general case, but they are valid if your initial string $$$t$$$ is monochrome (consists of letters of a single type) and has the same length so as $$$s$$$. Moreover, it is valid when string $$$t$$$ has a common prefix with $$$s$$$ and the remaining part is still monochrome. It is also can be proven (by induction I guess) that during these actions deletions and insertions are not necessary operations, because what can be done with these operations can also be done with changing letters in no more operations. I'll make the editorial more clean to understand soon.

    Additionally, it looks like when we are increasing a valid prefix in string $$$t$$$ on an initial monochrome string, the edit distance is actually equal to the Hamming distance.

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Can you prove these facts or post a link to the proofs for the same, as proving things is as much necessary in a contest(especially for greedy problems) as is intuition?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yeah I think you are right, take this case also: Edit distance between (aaaa , baba) is 2. The edit distance between (abaa , baba) is also two.Even though only one character has been changed from a to b.

»
5 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

Could anyone explain why the solution of problem C answer for the below case is 2?

3 5 2 100

0 0 1

5 5 5

If student leave at 5, he must solve all the problem. Am I misunderstanding?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    he can leave at 4, solve problem 1 and problem 2, which costs 4 minutes.he doesn't need to leave at 5

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

explain test case no 8 of 1282C — Petya and Exam how it is 1 it ans should be zero

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I am getting WA on test 2 on C.

https://mirror.codeforces.com/contest/1282/submission/67600070

Can Someone Please Help.

Thanks

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    instead of starting from the beginning, I have for once solved all the questions and then am deciding from the end, If the solution is permissible or not(depending on time limit, and if the next question is mandatory within that limit)

»
5 years ago, # |
Rev. 2   Vote: I like it +10 Vote: I do not like it

Based on your editorial of problem E, I think one can do simpler things to solve the problem:

  • To find $$$q$$$, consider the fact that whenever we cut off a triangle, we lose a vertex, i.e., it no longer appears in any further triangles. So, simply maintain the frequency of all the vertices (the no. of triangles it appears in) and also the triangles that contain the $$$i$$$-th vertex. At every step, choose a vertex that has a frequency of $$$1$$$, and cut its corresponding triangle.
  • To find p, consider every triangle. It has $$$3$$$ edges. Since only a single edge corresponds to the vertex of the polygon, and it appears only once in the input, we construct a graph on n vertices. We compute the count/frequency of all the edges in the input and for all edges $$$(u - v)$$$ that have a frequency of $$$1$$$, we add an edge $$$(u - v)$$$ in the graph. Now, the graph will be in the form of a simple cycle corresponding to the order of the vertices in the polygon. So, simply perform a dfs to find $$$p$$$.

Here, we have found $$$p$$$ and $$$q$$$ independently.

Code: 67604806

»
5 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

I dont get why the answer to test case 8 of problem c is 1 and not 0. In that test case the problem with lowest mandatory time is the third one, so if we want to solve one or more problems we must solve this one, but because the time it takes to solve this problem is 6 seconds, and there is a problem which its mandatory time is 6, we can not solve the third problem without solving this one or getting a zero score.So why is the answer to this test case 1? I am probably missing something here but i cant figure it out. Can someone please help me? edit* I found out how it can be 1.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    did u find the answer?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Solve an easy question and leave the exam

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        But after solving s become 6 which is equal to next ti,so it became mandatory,how can he leave the xm

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

queryforces

»
5 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

My soln. is similar to one which is mentioned in editorial and it is passing for problem B1 but failing for problem B2. I am not able to find out the mistake. Please help.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think sum += ar[i] should be replaced with sum = ar[i].

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

please, can anyone tell me that why in b2 editorial solution first loop run upto only k ? why ? please, anyone reply guys.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Because if you buy greater than $$$k$$$ items without using the offer, you would spend more money, rather buy $$$k$$$ items using the offer and buy others individually.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For me personally, finding permutation of vertices was far easier than finding an order of cuts.

»
5 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Do I have correct idea for problem E?

https://mirror.codeforces.com/contest/1282/submission/67669011

Idea:

Store vertices like graph. 1 piece = 6 new edges. Sort vertices by number of neighbors. On each step poll vertex V with smallest number of neighbors. V must have only two neighbors. Delete V from its neighbors. Add these two neighbors back to priority queue. Repeat while there wont be only two vertices.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why does the link to the editorial of this round appear twice? https://mirror.codeforces.com/contest/1282

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can someone figure out what's wrong with this solution for D? 67670033

It has a similar idea as given in the tutorial.

unreal.eugene

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Nice testcase 67 in D.

»
5 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

-3 1 2 0 how is the answer to this query for problem A 4?shouldn't it be 5? while travelling : -3 -2 -1 0 1 ,nowhere is tower signal available.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    same Confusion!! Did you find the answer?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I got the idea. We need to count distance and not number of points. So, -3 to -2 -> 1 -2 to -1 -> 1 -1 to 0 -> 1 0 to 1 -> 1. So, answer is 4.

      • »
        »
        »
        »
        5 years ago, # ^ |
        Rev. 3   Vote: I like it 0 Vote: I do not like it

        Well if that so in this test case answer should have been 6 : 1 10 7 1 : as, 1->2,2->3,3->4,4->5,(available for 6,7 and 8)8->9,9->10.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Invalid distance are 6->7 and 7->8. valid pairs 1->2,2->3,3->4,4->5,5->6,8->9,9->10. hence,answer is 7.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Could anyone help me to see why I got RE? TIA! 68362298

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I doubt that the checker of Problem D calculates incorrect Edit Distance when $$$|t|>|s|$$$ because 68363205 got WA on test 1. Can anyone help me about this? Thanks.

»
4 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

can someone explain the algorithm to problem B2

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it