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

Автор Nightmare05, история, 4 года назад, По-английски

Hi guys,

I would like to thank all participants for making this event a grand success and specially thank ck98, darklight13, LightYear, kunj017, scameeer, leviOosa and hackcyborg for the problem setting and testing efforts and specially for actively managing the queries during contest!!

So, without wasting more time I'd like to congratulate our winners:

  1. nuip

  2. Amoo_Safar

  3. fugazi

  4. kimden

  5. scopeInfinity

Based on the leaderboards following people have qualified for prizes:

Overall top 3:

  1. nuip

  2. Amoo_Safar

  3. fugazi

Top 5 Indians:

  1. fugazi

  2. scopeInfinity

  3. cerberus97

  4. _shanky

  5. hitman623

Top 2 from IIT Patna(presently studying):

  1. intruder_p

  2. DeepThought42

Winner from 1st year IIT Patna

  1. pac-man21

Editorals!

Is It Some Space Cakewalk?

Problem Author: darklight13

The main idea for problem was pigeon-hole principle i.e in worst case we pick all the different type of cakes first and then any additional cake would make a pair repeat. So the answer to the problem was number of different types of cake in the list + 1.

Time Complexity O(n+max(T)).

Author Solution

Kunj Destroys Asteroids in 13th Dimension

Problem Author: darklight13

This problem can be solved in many ways like prefix sum , window sliding or even binary search.

I will discuss one with partial sum. The equation of the rhombus can be represented by |x| + |y| = X. Thus we only need the manhattan distance of the points. We make a prefix array that will store number of points less than or equal to manhattan distance i for each i. We calculate the points lying between X and X+K using prefix sum for each X where X is prime which can be computed by sieve. For each X the number of points lying between the rhombi would be pre[X+k] — pre[X-1]. Maximum of all such iterations will be the answer.

Author Solution

1-2-3 Subsequence

Problem Author: scameeer

The naive solution of iterating from l to r for each query will give TLE. Thus we use segment tree. At each node in the segment tree we store 6 values. 1. Length of maximum subsequnce strating from 1 and containing only 1. 2. Length of maximum subsequnce strating from 2 and containing only 2. 3. Length of maximum subsequnce strating from 3 and containing only 3. 4. Length of maximum subsequnce strating from 1 and containing only 1 and 2. 5. Length of maximum subsequnce strating from 2 and containing only 2 and 3. 6. Length of maximum subsequnce strating from 1 and containing only 1, 2 and 3. Now when building the segment tree you can maximize these values at each node to get the answer. At each node combine when with possible combinations like 1+(2-3), (1-2)+3, 1+(1-2), (1), (2), (3), (1-3)+3, 1+(1-3). The answer to each query will be the maximum of the above values. This can be better understood in editorial code. A much clean solution can be: https://codeforces.com/blog/entry/71357?#comment-558146 Thanks to fugazi

Author Solution

Universe is random, but is it?

Problem Author: Nightmare05

First off, we begin by observing that since average of a child is his average over all exams he appears in, the expected score of a child is independent of E (the number of exams he appears in) and by a similar argument the answer is independent of N (number of students) as well. So, we know that answer is a function of M (maximum marks) and K (number of re-evaluations only) f(K,M). And now observe, a child would go for re-evaluation only if he scores less than or equal to f(K-1,M) else he won't go for further re-evaluations.

Author Solution

Divide the Country

Problem Author: LightYear

For this problem in particular we saw a lot of creative solutions. But still for the sake of editorials, here is the solution we thought.

First, check if the given graph is a tree. If yes, then output n — 1. If not then there exists at least one cycle. Choose any vertex which is part of a cycle. Let's call it u. Run dfs from u. Now suppose you are currently at vertex v. If there is a non-bridge vertex in the dfs subtree of v then you obviously cannot remove the edge between v and its parent and it is no longer a candidate for the answer. After checking that condition if the edge between v and parent of v is still a candidate then it means that the dfs subtree of v consists only of bridges. Keep track of the diameter of the subtree. If diameter is same as the current maximum diameter then check for the number of nodes in the subtrees.

Author Solution

Will You Win The Prize?

Problem Author: leviOosa

The question is given as if it has to be solved online, but actually it is an offline question. Take all the characters given in all queries in sequence to make a string (S1). The given string is named as (S). Make string (T)=S1+#+S. Now apply “KMP” on this string (T). In the array obtained by KMP take the answer from (n+1)th index to (2n)th index. This is our required l(i). So, ans(i)=l(i)*2^i. It’s easy to calculate the binary representation of ∑(i=1 to i=n) ans(i). Refer to the solution code for better understanding.

Author Solution

Yet Another Permutation Array!

Problem Author: scameeer

With the given cumulative sum array A, find out the elements in the array P. This can be easily done by knowing how cumulative array get build. The first element of the cumulative array will also be present the array P. The rest elements can be found using A[i]-A[i-1] for all i>=1 to n-1 (0-based indexing). Now in these conditions answer will be -1: 1. The number of distinct elements in P are not n. 2. If the distinct elements are n, all integers from 1 to n are not present. This can be done by storing the above made P array elements in set data structure and iterating them. In all other cases answer exists. Print the array P formed.

Author Solution

Binary Matching

Problem Author: Nightmare05

Since a lot of people were interested in the proof of this problem specially, I decided to write a complete rigorous proof and well since some stuff is mathematical I am writing on paper and uploading pics. Pic 1 Pic 2

Author Solution

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

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

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

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

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

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

can you give a brief outline for "Universe is random problem", how you got that formula , also the problem statement is not so clear with no explanation for sample test case.

i understood that N is irrelavant but why is E ignored in solution what happens if E<K , wouldn't that be a problem as now you can only take that exam E times .

please explain this line "And now observe, a child would go for re-evaluation only if he scores less than or equal to f(K-1,M) else he won't go for further re-evaluations." what does this mean .

is the problem asking for expected average score of a student if he's allowed to take the exam uptil K times and each time he can get a random number from [0..m]?

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

    Bro the problem was trying to say that each student has to give E exams irrespective of anything, going for re evaluation means just re-grading an already given exam, in re-evaluation you do not appear again for an exam, so E and K are independent of each other and the expected marks in 1 exam would be same as average expected marks over E exams irrespective of E, hence the answer is independent of E.

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

    See bro as of the line f(K-1,M), after a student gave an exam, and it got graded, since he is mathematically sound enough, you had to observe that he will be willing to go for re-evaluation only if his score is less than f(K-1,M). f(K-1,M) is the answer if only (K-1) re-evaluations were allowed. Else he would just keep his marks. In simpler words assume that M=100 and K=1, so a student who got more than 50 marks directly, won't go for re-evaluation, rest would go for re-evaluation.

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

Can you please make the test cases for the problems public? I wasn't able to figure out the mistake in my code for the problem Will You Win The Prize?. So, I would like to see the test case to see where was I going wrong.

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

https://ibb.co/s3VmPZf Can you check this box?