chokudai's blog

By chokudai, history, 6 years ago, In English

We will hold AtCoder Beginner Contest 180.

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

We are looking forward to your participation!

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

| Write comment?
»
6 years ago, hide # |
 
Vote: I like it +39 Vote: I do not like it

Wow that's an early announcement

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

How to solve D?

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

How to solve B(only Euclidian distance part) and D ??

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

Solution for F, anyone?

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

    Let DP[n][m][b] be the number of ways to build a graph with n labeled nodes and m unlabeled edges with b being a flag for restricting the size of the maximal connected component.

    From there at each iteration and to avoid double counting you only look at the components covering the first node.

    For example if I want a component of size 5 and n = 10 first I find the number of ways I can choose nodes to form this component which is 9 choose 4 (node #1 is already included). Then I find the number of way to build a path (5! / 2) or a cycle (4! / 2) and call the appropriate state.

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

      I didn't get how are you avoiding double counting?

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

        cause if you reverse a chain, the result will be the same as the origin, so there are k!/2 ways to form a chain with size k, or you will count a chain twice.

        as to circle, you should consider symmetry and shift, so there are k!/2/k = (k-1)!/2 ways to form a circle with size k.

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

          He is referring to the over counting of the total number of ways to make the connected components using DP, not the over counting of a particular component itself.

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

        sorry, i misunderstood it.

        for example, with node 1, 2, 3, 4 and 5,

        • choose 1,2 to form a component, and then choose 3,4,5 to form a component.
        • choose 3,4,5 to form a component, and then choose 1,2 to form a component.

        these 2 ways generate same graph, but if you count it more than once, then double counting happen.

        if you only look at the components covering the first node, you will only count the first way.

»
6 years ago, hide # |
 
Vote: I like it -19 Vote: I do not like it

How was E intended to be solved? I just copy pasted a DP code from stack overflow and calculated distances of graph[i][j] using the formula in the question and got AC.

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

Was solution to E was intended to be solved using floyd warshall and then tsp, or did I do some overkill ?

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

    I don't think you need floyd warshall. Since the distance metric used always gives shortest path between two vertices.

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

    I solved it using dp

    hint1
    hint2

    my code :

    Code
»
6 years ago, hide # |
Rev. 2  
Vote: I like it -8 Vote: I do not like it

This is my solution to B problem, can anyone tell me why it's WA My code

Edit: After Changing everything to long long, it is working now, even long double didn't work, can anyone explain to me why long long is working and remaining are not.

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

    Try long double instead of double, and sqrt instead of pow.

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

      Tried now, but still shows WA, can you please help me out and point the mistake in this

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

        You have to take max of absolute of arr[i] instead of just arr[i] to calculate 3rd distance. This is the same which I did and llost 700 ranks bcoz of that

        EDIT: sorry I overlooked that part.

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

How to solve Problem F? DP?

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

Hi, could someone point out my mistake in B

Edit: But x[i] is long long right?

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

Could someone help me.. i dont know why my dp runs incorrectly :< https://paste.ubuntu.com/p/nrYYHqvxw7/

»
6 years ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it
  1. TLE
  2. AC Solution after contest 4th problem why anyone?
»
6 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

How to solve d please explain anyone?? i was thinking it was dp but other's solution just amazed me

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

Why this solution gets TLE while this gets AC? Using int instead of long long should result in wrong answer instead of TLE, then what other reasons behind it?

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

    For bigger values of n, i * i will overflow and will result in i * i <= n being true.

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

Please can somebody explain why using even unsigned long long is giving WA on D? I tried different values of x,y,a,b and checked but they were all running fine, but during contest ((ull)x*a<2e18) dosen't work but ((double)x*a) worked; why??

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

How to solve E?

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

I have a problem with B. I am using long long and long double wherever needed and I am still getting compilation error. I think I am getting an error while using "abs(x)". Here's my code, plz help : problem B

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

    There are a few problems:

    The error with abs function is due to ll being defined as unsigned.

    Then after this, you will be getting a WA because you have your cd as cd=max(cd,x) instead of cd=max(cd,abs(x))

    After that, you still are getting a WA because you are submitting problem B's solution for problem A :)

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

Hello guys, I need your help on my solution to the third problem. Here's a link to my submission, I kept getting TLE. How could I have optimized my solution? https://atcoder.jp/contests/abc180/submissions/17476685

On the second problem, I was flat out getting Wrong Answer. What was wrong also? https://atcoder.jp/contests/abc180/submissions/17474677

Thank you very much. PS; ABC 180 was my first CP contest, so also, any general tips for CP will do.

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

A question: How much would be the corresponding rating of problems C, D and E on codeforces?