Comments

HackerCup 2023 edition has been announced: https://www.facebook.com/codingcompetitions/hacker-cup/

Dude's a life saviour! All hail zibada. orz!

On kirigannNo Contest for 9 days?, 3 years ago
+3

Its practice + virtual contest time

On mon0poleCodeJam Round 1A 2022, 4 years ago
0

Thanks!

On mon0poleCodeJam Round 1A 2022, 4 years ago
0

Can you elaborate?

On IgorIHello 2022 Editorial, 4 years ago
0

I thought I had a counter example. But I evaluated it wrong. My code is working perfectly fine in it. We still need help from someone!

On IgorIHello 2022 Editorial, 4 years ago
0
1
4
1 100 50
1 10 20
40 50 20
1 5 5

Sorry, your code is working perfectly fine in this testcase. I evaluated it wrong. Even my submission is giving the same expected answer.

We need some other testcase!

On IgorIHello 2022 Editorial, 4 years ago
0

Need help in finding a test case where my code fails for Problem B! Link to my submission

No T-shirts or Certificates on the ICPC website!

Did your team get the T-shirts yet?

Yeah! The point is to use file i/o or input output redirection(using either Get-Content or redirection symbols ">" and "<") and not copy paste the whole input. It is bound to crash. The only case for opening the input file is to have a look at the testcases.

In Windows, if you have Git bash, then use this(after compiling it): ./Facebook < input.txt > output.txt or if using Powershell then use the following: Get-Content input.txt | ./Facebook > output.txt

At least, it worked for me!

You may try using Sublime Text!

When will the solutions to some of the Hacker Cup editions be made available e.g. 2011? It would be great if they could be added to the solutions tab just like solutions are posted this year.

Not yet

Has Amritapuri Region released the certificates of Participation for Regionals and Preliminary Round? Balajiganapathi

They are working on it

How does the Friends feature work? Does it only take literally Facebook Friends or we can somehow mark someone as Favorite as CF or Google Competitions?

Cool. I will try the former and let you know if I face any difficulties!

If I find a mistake in any of the article, how can I report it?

Could you explain your solution a bit more? Obviously adding edges in u1 to u2/v2 i.e. across Diana's and Mocha's forest doesn't make sense.

In problem D2, can someone explain the this line about the time complexity," This is because an element moves to a new row/column O(logn) times and each move is O(logn) time (using STL set in cpp)" with respect to the operations that are happening. I understood the operations above but not able to figure out the time complexity. To me, it seems more like O(logn)+O(logn).

Can you send the link to your submission? Just curious to see the implementation

A link to your submission may be to clarify things.

Take the input from about the training of each candidate as an pair from with its index. It is optimal to take only one T[i] and do it q times. Prepare two more arrays, say left and right which would store the best possible sum while coming from left(and from right) and including that element. If this increase (T[i] > 0), For each of those index find the max value by U[i] + (T[i]>0)?(T[i]*q):0 + (i>0)?left[i-1]:0 + (i<n-1)?right[i+1]:0

Time complexity: O(n) [You do Linear time preprocessing to create left and right + Final Traversal through T with O(1) usage of left and right]

Would love to see how others solved it.

eg. U = [-3 2 1 -20 3] left = [0, 2, 3, 0, 3] right = [0,3,1,0,3]

How many did your team solve?

On rajutsav1234Which is faster?, 5 years ago
+12

Based on the content written at the page 45 of Competitive Programmer's Handbook, sorting is usually faster for solving the problem. Although the discussion on the page is about set vs unordered_set vs sorting, I believe similar arguments would hold true in case of priority_queue also.

0

If you implemented these, could you please add them to the editorial above. Novice people like me learn through implementation off problems much more than plain comments.

You can get that from ICPC Baylor website in the Attachments section of your team once they release it. You can check that, if you participated last year.

Okay. Makes sense now. Thanks

Can you elaborate on how is this used in the problem?

I was finally able to register after lots of attempts.

Is the Coach supposed to do the full Team registration or the Contestant create the Team themselves and the Coach verifies/accepts it? In any case, we are still getting the "Request failed with status code 503" error! Neither is our Coach able to create the Team or us. I have mailed at these mail ids as you instructed.

Check out the increment function in the my submission

It just takes in any random strings and make it work like a counter.

Problem E Explanation shows Math Processing Error in Major Browser like Edge, Chrome or Opera. How can I get rid of it?

Your testcase is missing from the box. Could you please make it in plaintext?

Somehow my solution is giving Wrong answer on testcase 2. Expected value is 10, but my solution gives 9. Well, I am not sure why my code is giving less value than the optimal answer. I used the following approach of finding the minimum for odd and even indices respectively which minimizes the total answer.

I cannot understand why is it failing? Please help! My submission

Thanks! I will look into it and get back to you!

Why does my code give Time limit exceeded in Testcase no 4? I am not able to figure out where is my code breaking!

Link to my code

In addition enabling the cin.tie, sync_wih_stdio etc. part causes idleness limit exceeded. Someone please help me!

Link to my code

If anyone can send a link to their solution it would be helpful in that way also. I am unable to open the submissions of other people.

Update: Problem solved! Please ignore this post!

Keep a count of the cars on each street and allocate a time = count()/40. The number 40 isn't specific. Just experimental. You might try dividing by 10,20,... etc and see how do the results vary.

Can you throw some light on how exactly did you find "the optimal order of streets by simulation". We found it pretty difficult to convert the data into output format even though we could store the streets that were used by the cars during a particular second(in some array from 1 to D seconds). But no idea after that.

Would it be possible for the google hashcode team to create a submit button which automatically takes all the files or the specified ones on a single click on the submit button. It was extremely painful to do each file submission manually(along with source code). Or at least someway through which we can submit all files in one go. Our hands become tired pretty quickly clicking again and again on the mouse(since we doing a lot of trial and error)!

Some suggestions from the community on how do they deal with this issue are welcome on this!

Can you upload your stream for this year's hashcode with commnetary or do a livestream on the extended round going on? It would we great help for everyone!

0

I am a bit late but just in case if it helps you. The questions wants you to find if there is any cell in which there odd number of adjacent cell containing 'o'. You can go through complete 2-d array and count the same for each cell and print the answer accordingly.

Here is link to My submission if you want to cross check or something.

I think if the last '0' is changed to one, it is still is a good testcase which serves the purpose of highlighting that 2*a[i]+b[i] is correct rather than a[i]+b[i]

0

This testcase just blew my mind. Thanks a lot!

0

Someone please help me in finding a counterexample for my submission

0

I had almost the same approach, but still WA. Can you find a counter example?

But you have written a floor in your formula. I was replying to that. I know that it can be done with simple division. I got FST in Q1 because I wrote floor unnecessarily. That's why I pointed out. Nothing much!

If you read the question carefully, it says the sum of the values of "n" don't exceed 10^5. It doesn't place any restriction on the values of array itself. It is only on the number of elements in the testcase. Due to this, you can have a testcase which has 10^5 elements, each of which are 10^9 which easily overflows in your case.

I hope it clears up things for you.

Don't forget to typecast (long long) in front of floor function. I learned it the hard way.

Don't you face the same issue with coding also? How do you balance your time to manage your eyesight now? Some tips would be really helpful.

On OkrutGood Bye 2020, 5 years ago
+16

Please do upload your solutions for the contest on youtube after the contest is over.

When you divide 81 by its proper divisor you will get 3, it will take two more steps to reach 1. Hence, the answer is 3 (and not 2). The same applies to 21 also. Remember that the goal was to reach 1.

As far as I know, the last date to apply was 10th August. Maybe you can check on Carrier page of Google and apply from there.

Thanks for the problem!

I just finished reading about segment trees and LCA. But I am still not sure what function are you using for building the segment tree. Because we need the number of nodes having weight less than equal to w. Could you expand a bit on that part?

I got the problem. I misunderstood the reordering part.

The code which I wrote (for Balancing Game) is working for all the testcases I think of. It would be very helpful if someone could provide some counterexample.

Link to my submission Balance Game

I used the concept of subset sum to approach the problem and shifted all the number to positive by adding the min element to all the numbers.

Please help.

But I think it can be implemented if we maintain a pair of slope and y-intercept. And resulting time-complexity would be O(n^2logn).

"Now if a slope appears more than once(by that i mean if two or more pairs has same slope) than there must be a line that passes through these(atleast 3) points". I think it is not necessarily true because we may have parallel lines. Am I right?

Okay, so the working will be as follows:-

  1. First our friend finishes the first two bosses "1 0".

  2. When we see a "0", we exchange the last boss finished, i.e. "1" one done by friend, the next "0" is done by me and the third "0" is done by friend.

  3. This way, in the next turn we get to finish the next two hard bosses "1 1" and we are done.

I wrote a code for this idea with comments:-link to submission.

Did I explain your question?

Greedy solution does work, though it uses a little bit of coming back a step

greedy solution with insights

Check the link solution

Your array might be accessing elements out of bounds. This could lead to unpredictable results. 'a' is a vector or array?

Is it working with

0 0 0 1 1?

Answer should be 0

We will not have the ripple back effect because we are always alternating turns and each player can at max handle 2 jobs. When you get a 0 in second place, the friend will take care of it, if we get one more 0, we redistribute as follows:-

First(it may be 0 or 1) one is done by friend, second by me and third one by friend again.

If you have any counterexamples in mind, please share them?

How did you find the testcase?? Amazing!

I think I just got why your solution works.

The key realization is when you are skipping, you can actually imagine that as transferring the previous job to me(basically take it away from friend). Then it, doesn't matter whether it was a 1 or 0. It will not affect the answer. The special case is when there is a 0 at the second position. This time you cannot take the previous job, so we imagine that our friend finished the first two bosses. If in the third position, we have a one, "I" will take care and if it is a zero, then we again imagine a redistribution of work in which first job was done by our friend, second one by me and third one by friend again. This way, the solution always yield the optimal answer.

Exactly! When we don't skip it shows WA at Testcase 55.

What about this line: During one session, either you or your friend can kill one or two bosses (neither you nor your friend can skip the session, so the minimum number of bosses killed during one session is at least one). After your friend session, your session begins....?

In the code by sh_maestro, he is skipping the case when it is your turn and a[i]==0 then he is skipping the boss.

        if(turn) 
        {
	    if(a[i]) 
            {
	      ret++;
	    }
	    i++;
	    if(i>=n) break;
	    if(!a[i])
	    i++;
        }
	else {
	     if(a[i])    //Why adding this line makes this code AC?
	     i++;
	     if(i<n && a[i])
	     i++;
	}
	turn = !turn;

I don't understand why does it lead to correct answer?

In the code you have provided in the link, if its my turn and the a[i]==0 then, you have skipped the testcase. I can't understand that part.

That helped a lot! I got another problem which gives the same feeling as this one but I am not sure how LCA will be helpful here. The problem is as follows:-

You are given a undirected tree with v vertices where each node has a specific weight given as an array. We need to answer q queries. Each query consists of source and destination and a number w. For each query we should return the number of nodes having weight of at most w in the path from source to destination.

Constraints:- v,q <= 2*10^5

Any ideas about this one?

Thanks. This is a new topic for me. I need to learn it first. Thanks for the link.

Auto comment: topic has been updated by pks18 (previous revision, new revision, compare).

In the problem of alien invasion, the cool down time was a floating point value. How do we know when to stop it? I am confused in that.

Still I would like to just check the link.

Google Internship Test, is it online? Can you provide the link?

I am using a simple greedy approach of adding the new 0/1 to which it is eligible. If not possible, I create a new one. But still it showing WA on test set 2. link to my code. Can some body give me the testcases where it is failing?

On pks18Minimize the number of Dogs!, 6 years ago
0

Are you suggesting to connect all the sheep with all the wolves with an edge capacity of one and then find the Min-Cut. If yes, how would you model the case where you four sheep are placed at the corners of the field and yo have sheep at the center?

On pks18Minimize the number of Dogs!, 6 years ago
0

I think I didn't understand how to use max flow-min cut to solve the optimization problem. Could you elaborate it more?

On pks18Minimize the number of Dogs!, 6 years ago
0

Suppose all sheep are on one side and all wolves on the other side, we can put dogs in the between them. That can have less number of dogs in many cases of r and c. I think you get the idea.

0

You have not initialized the map but used, does it automatically return zero or I am missing something?

Thank you very much! It was very blunder mistake but very difficult to catch for me. Thanks again.

Same condition for the Tutorials too!!

After 6 failed attempts, I am still unable to figure out, why is code for Problem C failing? Can anybody help me. Please!! Here is a link to my submission

When are the editorials going to be uploaded?