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

Автор chokudai, история, 6 лет назад, По-английски

We will hold AtCoder Beginner Contest 173.

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

We are looking forward to your participation!

  • Проголосовать: нравится
  • +75
  • Проголосовать: не нравится

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

Participate, we must.

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

Hope that C is not the killer this time :p

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

See you all on the scoreboard!

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

How to solve D?

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

What the hell with me . can solve D but not c ..everytime stuck on c..

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

What's the approach for F ?

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

Brief Editorial :

A
B
C
D
E
F
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится
»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve E and F? Thanks in advance:)

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

    E: case out n==k, and when everything is negative.

    Otherwise, you can repeatedly remove the smallest two nonegatives and replace them with the largest two negatives as long the product of the two negatives is bigger.

    F: You can consider nodes and edges independently. Each node contributes +1 to the answer, each edge -1. You just need to count the number of ranges each node and each edge is part of.

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

      In E why after sorting both positive and negative numbers then repeatedly removing pair from the end which has maximum value(product) and if k is odd and there are only 2 positive numbers left then only removing pairwise from negative numbers didn't work?

      For odd K when i first removed the largest positive number separately and solve the rest for even k worked, why?

      WA AC

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

        Consider this testcase:

        5 3
        -2 -1 1 1 3
        

        The first method will select 3 and 1 since 3 x 1 > (-2) x (-1). Then it has to select 1, the only positive number left. However, 3 * 1 * 1 < 3 * (-2) * (-1)

        That problem can be remedied by ensuring that whenever two numbers are selected together at either end, another two numbers will be selected at either end unless no more element will be selected. It is easy to show that strategy cannot be wrong.

        That is why the second method works, because for even K, the maximum product, if it is greater than 0, must come from even number of positive numbers and even number of negative numbers.

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

      Your solution for E is just brilliant. Thank you

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

    For F for every segment think that every element is disconnected, and their contribution to answer is the length of segments. Now for each edge see in how many segments it can occur and subtract that number from answer.

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

Ok! can anybody tell me how to solve C? :)

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

E was on codechef as MMPROD.

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

Wow, E took me forever (and a lot of WA and lots of messy casework). Wondering if anyone has a cleaner solution.

(My messy solution: https://atcoder.jp/contests/abc173/submissions?f.Task=abc173_e&f.Language=&f.Status=&f.User=AnandOza)

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

Defeated by Mod ;____;

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

can we see others submission? if yes then how?

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

    If you want to see submission of a perticular person then, go to standing hover over the username and click on the searching symbol (magnifying lens). You can also do that by writing the username in all submissions. But I like the first one this way I can see the fastest submissions.

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

Can somebody guide me to an article(or anything for that matter) which has good theory on bitmasking? Couldn't solve C this time! (easy to read)Code for A, B, D, E @ https://atcoder.jp/contests/abc173/submissions/me

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

For D, getting WA on 9 test case , please help, what's wrong in my code. https://atcoder.jp/contests/abc173/submissions/15012383

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

For Problem E

First

Second

First code is not working for 2 testcases so i added one if for k==n that is second code and Second code is not working for 3 testcases. I can't understand how it is possible can anyone help me?

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

I tried E by sorting all the numbers. If all the numbers in the array are positive the max product of k numbers is last k numbers. otherwise, we need to find the maximum of the first k numbers and the last k numbers and print the maximum. What is wrong with this logic.

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

can someone please help out with C?

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

I didn't even understand the problem statement of C.. xD

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

Anyone's comparing summation of log2()s failing for E?? can anyone explain how to overcome it??

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

What is wrong in this :

Try to take even number of negative numbers starting from descending order and multiply with even numbers left , again in descending order.

If the above is not possible, then check if a zero exists.

If a zero exists, ans is zero else answer has to be negative.

SO, try to take odd number of negative numbers in ascending order and choose remaining numbers as even, again in ascending order ?

https://atcoder.jp/contests/abc173/submissions/15018728

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

Anybody used gfg's code for problem E?? If yes,please share your sol, i want to see my mistake!

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

Can anyone explain how to approach C ?

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

May somebody help me debug my code? Getting WA on one testcase. https://atcoder.jp/contests/abc173/submissions/15021212

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

can anyone explain the approach of Problem C , I was able to solve A, B, D but not C. https://atcoder.jp/users/aniketakgec/history/share/abc173

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

    Simple brute force, try all possible combinations of rows and columns that are to be painted and simply count the no of black cells left in O(h*w) for a particular combination, total time complexity — O(2^h * 2^w * h * w)

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

Someone please help , why my logic is wrong in task D:

In D , i observed a pattern , suppose if we sort array , then :

Best optimal way to gain points is :
0 , a[n], a[n-1],a[n-1],a[n-2],a[n-2],a[n-3],a[n-3],etc... (k times)
But i got WA .
Code
»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

What is wrong with this code of E-

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

Initially, problem C had the constraint H, W <= 13 and needed DFS and pre-calculation :(

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

In problem E-Multiplication 4 I was checking whether they have this kind of test case 5 4 1 2 3 -1 0 in their test set or not.

so, I removed one condition in my code and got AC instead of WA.

Output produced by AC code is 1000000001 ( -6 % (10^9 + 7) ) you can see here. Where the correct answer is 0.

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

OMG I misread problem E as maximum of all possible k length subsequences (a1*a2*a3*....ak)%(1e9+7). How to solve this task?

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

Got WA in B due to writing capital 'X' instead of small 'x'

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

My submission for E is giving WA for 5 tests. Actually I tried only limited cases:

First I sort array of absolute value of numbers descending order

  1. If first k have even number of negatives, we got our answer

  2. Otherwise we remove smallest negative and search for a positive among remaining n-k elements. If found positive, then this is an estimate.

  3. Another estimate is dont take one non negative among first k elements and search for a negative in remaining n-k elements. If negative is found then this is another estimate.

  4. If none of 2, 3 occurred then we know our answer must be negative so we chose last k elements as estimate. Otherwise we chose biggger of 2, 3.

Is this wrong? While writing this comment I realised that I havent checked which one of 2, 3 yields greater value. ;p submission link

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

I had a problem with E, most of the test cases passed but I don't know why I was not able to have AC on E. can anyone help me ? here is my the link to my code https://atcoder.jp/contests/abc173/submissions/15005580

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

English editorial may be helpful for all coders.

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

Can someone tell me why this solution is failing on certain cases.

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

I have submitted several times and still getting WA on three specific cases. https://atcoder.jp/contests/abc173/submissions/15025193

Is anyone stuck in the same cases to give me hand, because I have really no idea what is wrong. My main logic is to get the max K numbers and apply a replacement when the parity of negatives is an odd number.

Thank you !

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

In Atcoder the correct order must be A, B, D, C. Thrice in a row I was not able to solve C. Can anyone help pls. :(

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

please explain solution of C in easy language..

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

In D question, why can't the max element be added more than once? For example, consider the case :

5

2 2 3 3 3

Won't the max element be added more than once here??

UPD: I understood. Ignore this comment.

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

My code passes all the tests except one. I can't figure out any mistake. Please help. Link to my submission

Edit: I got my mistake. Here is my new submission

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

What is wrong with this approach for E? I covered the other cases such as only negatives and k=n. So when both positives and negatives are there, we take biggest elements by absolute value in our answer and count the number of negatives. If number of negatives is even, this is our answer. Otherwise, I am trading the least positive value in my taken numbers with biggest negative value among left out numbers or trading least negative value with the biggest positive value among left out numbers, whichever is better. Any counter test case for this ?

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

Can anyone help me understand why this code fails for a few testcases https://atcoder.jp/contests/abc173/submissions/15031526

i inserted the element as pair where first = absolute value and second value = 0 if positive else 1 and sorted the elements using abs value.In case of all negative elements i picked first k elements.Otherwise i picked the last k elements and noted the number of negative values(say nneg) and also kept track of the first negative value i picked(say firstneg).ifnneg is even then i print the product else in the first n-k elements i first look for maximum positive element and failing to do so i pick the least negative value and multiply it by product and multiply it by inverse of the firstneg.

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

Can anyone provide proof for the problem D.

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

    Same here. the proof in editorial is not sufficient imho.

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

    Here is my proof not depends on people arrived in the decreasing order. Consider all the n-1 comfort we can get. I will prove: If there are k numbers >= x, others < x, then among all comfort we can get, there are at most 2*k-1 comfort >= x.

    We note these k person as nice person, and the position between 2 nice person as nice position. also we note comfort >= x as nice comfort. 1. There are at most k-1 nice comfort we can get when these k nice person arrive(first nice person can not get nice comfort). 2. when a nice person arrive, nice position will increase at most one, when a not so nice person get a nice comfort, he must decrease a nice position. so not so nice persons can get k nice comfort at most.

    so we can get at most 1 comfort >= a[0], 3 comfort >= a[1], and so on...

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

For E, what is the case 'after_contest_01.txt'? My code is getting 500 as it passes all the tests from the contest but fails on this one.

Note: It's also not in the TestCase Dropbox.

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

Can anyone check my submission for problem E : https://atcoder.jp/contests/abc173/submissions/15041696 it fails on just single case.Not able to figure out.

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

Please help in question E, why does this give WA????

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

What's wrong with my E submission? Submission

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

What wrong in my submission in E ,it's failing on 6 test cases https://atcoder.jp/contests/abc173/submissions/15042752 ?

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

    m_scofield, vkm23061998, your code fails for this TC.

    Input:

    8 6

    1000000000 1000000000 -1000000000 -1000000000 -999999999 999999998 -999999997 999999996

    Correct Answer:

    192080

    (By taking the first 4 numbers and -999999999 and -999999997)

    Your Output:

    237699

    (By taking the first 4 numbers and 999999998 and 999999996)

    Hope, this helps.

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

Someone knows What's in "after_contest_01.txt"? (Problem E)

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

For some (like me) who still couldn't figure out F

g(l,r): be graph of vertices[l,r]

e(l,r): count of edges in g(l,r)

f(l,r): count of connected components in g(l,r)

f(l,r) = count of vertices in g(l,r) — count of edges in g(l,r)

$$$\displaystyle\sum\limits_{l=1}^n \displaystyle\sum\limits_{r=l}^n f(l,r) = \displaystyle\sum\limits_{l=1}^N \displaystyle\sum\limits_{r=l}^n ((r-l+1) - e(l,r)) $$$ $$$=\displaystyle\sum\limits_{l=1}^n \displaystyle\sum\limits_{r=l}^n (r-l+1) - \displaystyle\sum\limits_{l=1}^n \displaystyle\sum\limits_{r=l}^n e(l,r) $$$

First part is easy O(n). For second part Let c(u,v) be number of ranges edge(u,v) contribute to

$$$c(u_i,v_i) = u_i*(n-v_i+1) $$$

Hence, $$$\displaystyle\sum\limits_{l=1}^n \displaystyle\sum\limits_{r=l}^n e(l,r) = \displaystyle\sum\limits_{i=1}^{n-1} c(u_i,v_i)$$$

PS: My first attempt at an explanation. I think there should be line-spacing option.

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

https://atcoder.jp/contests/abc173/submissions/15093804

Can anyone please check my solution? I am not getting anything wrong with my approach but getting wa continuously.

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

If anyone need Detail explanation (Not a video tutorial) for E Here