chokudai's blog

By chokudai, history, 7 years ago, In English

We will hold AtCoder Beginner Contest 151.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

  • Vote: I like it
  • +12
  • Vote: I do not like it

| Write comment?
»
7 years ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Hope that it's rated!!

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

How to solve F?

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

Hi, alex9801. You solved F in 2 minutes and 30 seconds!

Also, I just want to say that your code was written by me! :)

submission: https://atcoder.jp/contests/abc151/submissions/9442898

github: https://github.com/koosaga/DeobureoMinkyuParty/blob/master/teamnote.tex#L1535

  • »
    »
    7 years ago, hide # ^ |
     
    Vote: I like it +19 Vote: I do not like it

    Someone told me to check out atcoder for some quality problems lol

  • »
    »
    7 years ago, hide # ^ |
     
    Vote: I like it +21 Vote: I do not like it

    Strongly disliked this problem. You either copy-paste the solution or spend all the time googling formulas and end up far behind.

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

      I agree, but let's look at the bright side : We got to learn something new and possibly useful

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

        Agreed. I actually happened to know the O(n^4) algorithm (who didn't?), but this contest helped me find simple closed formula for the circumcenter.

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

F-Enclose All seemed to be binary search on real numbers, but I could not figure out how to solve keeping both x and y co-ordinate into account. Can anyone explain his/her approach towards the problem?

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

    I copied this. Explanation

  • »
    »
    7 years ago, hide # ^ |
    ← Rev. 2  
    Vote: I like it +10 Vote: I do not like it

    Smallest enclosing circle is either one of followings:

    • having two points as diameter.

    • circumcircle of three points.

    So, checking all possiblity, you can get O(n^4) solution.

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

      Is there a mathematical approach towards validating this assumption?

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

      My solution is $$$O(n)$$$: link(tbh i forgot proof)

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

      Can u please give the proof of above. How do the two conditions lead to the smallest enclosing circle.

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

        If either two points not diameter, or one point is on a circle, you can adjust center little bit, resulting larger circle.

        More explicitly, denote center as $$$C$$$, points as $$$P_i$$$

        • one point on circle: move $$$C$$$ toward $$$P_1$$$, and keep radius $$$CP_1$$$ until your circle meet other point.

        • two points on circle: move $$$C$$$ along line perpendicular with $$$P_1P_2$$$, keep radius $$$CP_1 = CP_2$$$ until it cannot be moved further or meet other point.

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

    I used two ternary searches. Take two potential x-coordinates on outer ternary search and for each of them calculate the best radius using nested ternary search over y-coordinates.

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

      I didn't go for this method because I thought the circle might not be unique, just found I was wrong about the uniqueness of the circle.

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

How to solve E?

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

    you can count the contribution of each element as 1. minimum and 2. maximum.

  • »
    »
    7 years ago, hide # ^ |
     
    Vote: I like it +9 Vote: I do not like it

    Sort all the values and calculate contribution of each element in the final sum. If the position is $$$i$$$, then contribution is $$$a[i]*(C_{k-1}^{i} - C_{k - 1}^{n-i-1})$$$

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

    It can be solved by just fixing the min and max elements and rest can be chosen arbitrarily from elements having values in between them. 1. Sort the array. 2. Calculate prefix sums. 3. After fixing the min and max elements in the array, there can be k-2 to n-2 elements in between the min and max elements. So loop over them and multiply the value with (no. of elements in between)C(k-2). Note: - C means Combination. - Keep % 1e9 + 7 into account as well.

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

    Sort the array, now notice that, you can choose all elements from k to n as the maximum number. Now if you choose i th number as the maximum, then you can take k — 1 numbers which are smaller or equal to i th number. so i th number will appear ncr(i — 1, k — 1) times as maximum.

    For minimum, we can choose numbers from 1 to n — k + 1, suppose you choose i th number as minimum, the you can take k — 1 numbers which are greater or equal to i th element. So i th number will appear ncr(n — i, k — 1) times as minimum.

    Then our answer is max_sum — min_sum

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

Why does this TLE in D. I did bfs from all the points. https://atcoder.jp/contests/abc151/submissions/9478877

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

Can someone help in telling the DFS approach to problem D? Why this is wrong

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

deleted

»
7 years ago, hide # |
← Rev. 2  
Vote: I like it -17 Vote: I do not like it

weak test cases for problem C and wrong answer in editorial

it not cover the case when WA for that question is present but contestant not submit any problem show "AC".

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

    What do u mean by weak test cases ? I forgot to check for case when WA is present and AC not present and got wrong answer . After I check that case I got AC. Also the editorial to the problem covers that case . Don't spread wrong information for no reason.

»
7 years ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

Geothermal Please make the editorial for this contest, like you always do.

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

Can someone tell me why this has WA for Problem E in a few cases? https://atcoder.jp/contests/abc151/submissions/9466294

I sum the contribution of elements that can be max, and the contribution of elements that can be min, and then subtract them in the end (S_max - S_min)

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

    Well I figured out what was wrong with it, and it turns out it could be one of those differences in compilers/configuration and handling of data types and so? In my code, I had #define mod 1000000007, when I change it to a declaration of a long long variable ll mod = 1000000007; the same exact code passes, here.

    It's weird, I've used this in many problems before without problem, so I am suspecting, something is off with AtCoder's settings, I could be wrong though. BTW, I did try declaring it as an int variable, but that doesn't pass. In either case, can anyone clarify or shed some light on this issue?

    RaunaqRoxx This looks like it's what's wrong with your code as well.

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

      If you use #define mod 1000000007 or int mod = 1000000007, you will get an integer overflow in cout << (mxS - mnS + mod) % mod << '\n'; if mxS = 10^9 and mnS = -10^9. So you have to use #define mod 1000000007ll or ll mod = 1000000007.

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

      Really nice observation but this is not the problem with my code, I made that change and submitted, still the verdict hasn't changed, I have stress tested my solution on very large test cases and could not find a fault, does anybody have any idea how can we view the test cases?

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

Here is my submission for problem D why it is getting TLE. I have seen similar soln passing

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

I will be really glad if someone can provide a test case where my submission for E is going wrong. https://atcoder.jp/contests/abc151/submissions/9484300 It's getting WA at 4/18 test cases but I cannot find any counter cases. I am doing close to what is given in the editorial.

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

I tried this gradient descent-like approach basically I check 8 directions of current point and go to the one with minimum radius (centered on that point) and break when the current point is smaller than all the 8 directions. I loop this several times with increased accuracy (double dumb). Can anyone explain why I get WA? I think its precision problem but I looped a lot of times. Any suggestions of improvements are also appreciated.

code
»
7 years ago, hide # |
← Rev. 2  
Vote: I like it 0 Vote: I do not like it

My Solution for problem D

Explanation : I used 2 BFS to calculate the longest path in the matrix. The first BFS (function name bfs1) gives me the coordinates of the road block farthest away from the start coordinates. The second BFS (function name bfs2) takes those coordinates (which we got from bfs1) and calculates the max distance.

More info. about this double-BFS method : Longest path in an undirected tree

Result : I passed all the test cases except for one (i.e. hand_04 test file). I don't know where I went wrong. Guys please help finding me this corner case or if my approach is wrong please let me know.

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

fpr E,why do i get WA when i calculate maxium but get accepted when I calculate minus first?

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

for E,why do i get WA when i calculate maxim but get accepted when I calculate minus first?

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

my solution Why do i get WA on C. I increment penalty for each WA for a problem untill it gets AC. Can someone please give me a sample case where it fails.

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

    Penalties for a problem don't count if it hasn't been ACed.

    A sample:

    $$$2$$$ $$$1$$$

    $$$1$$$ $$$\text{WA}$$$

    Answer should be $$$0$$$ $$$0$$$.