Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all 39796 articles
Browse latest View live

Rating Dropped What now?

$
0
0

My rating has been dropped because of plagiarism caught two times.

1st-time plagiarism:- One of my friends stuck in October long challenge. He tried for 3 days but he couldn't find testcase where his code was wrong, So I gave him my code so that he can make own testcases and see the correct answer from my code. I warned him to not copy paste my code, He didn't submit my code but his room-mate submitted my exact code(Don't know how ).

2st-time plagiarism:- Me and my friend are doing the December long challenge and we both stuck on one question which we had done with co-operation.

I received first plagiarism mail from Codechef on 1st Feb 2018 for 2nd plagiarism(Dec long challenge). Then I read CodeChef Code Of Conduct and The Cheating Cases Saga and I accepted my mistake and decided to not to do anything which violates Codechef rules.

8 April 2018 I got one more mail for 1st plagiarism(Oct long challenge). I was just upset that they sent me the mail so late.

I accept all my mistakes I should have protected my code.

I now want to ask what should I do:-

1). Should I make a new account and deactivate this account.

2). Or continue from this account (Ek nayi shuruvat :))

If I continue from This account than I want to know how can plagiarism dots on my graph effect in my future (like codechef's next plagiarism hammer or when some company reviews my profile for job etc.)


Fully solved problems showing "partially-solved"?

$
0
0

Hi! I am back to competitive and to CC after almost 3 years and a LOT has changed and feels good to be back! :) Just to regain the hang of coding I decided to not participate but to solve the Div2 problems which are given as practice in Div1.

I attempted all 3 and was able to solve completely(full score, all cases passing). However, on the contest homepage, it keeps indicating those as partially-solved with a yellow tick. They also appear under "Partially Solved" section on my account page :( One of the 2 pages is wrong - contest or my submissions and the account seems to be pulling info from that page!

alt text

Am I missing something here? Thanks!

Regarding the new rating division system

$
0
0

The March Challenge 2018 witnessed two parallel contests for the two rating divisions for the first time ever in Codechef. However, there are a few issues regarding it which I want to discuss.

Codechef clearly states that the problems in the other division can be practiced and are “NOT part of the contest”.

I had planned to skip this March Challenge as our college fest was going on. However, I tried those div 2 problems in practice and boom, my name appeared on the ranklist with score ‘0’! Now this really needs to be fixed… @admin

The second and the last issue is undoubtedly a petty issue. The div 2 problems once solved, shows a yellow tick even if it is fully solved. Even the profile shows the problems in the partially solved section. I don't know the reason behind this.

However, overall, I am satisfied with this division system and it does motivate all the coders to strive hard for that green tick.

False acquisition of plagiarism.

$
0
0

Here is what I recieved after the May Long Challenge 2017. alt text

As you can see, both the submissions were same. I had e-mailed them at that time, but I didn't get any reply. Some days ago, when I checked my account, I saw my ratings were dropped by 645 points. After that, I again messaged them in facebook, but no reply came. Please see to it that I get my ratings revived.

DOBDELIV - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Aditya Paliwal
Tester:Teja Vardhan Reddy
Editorialist:Aswin Ashok

DIFFICULTY:

EASY-MEDIUM

PREREQUISITES:

DP

PROBLEM:

You are given a M x M grid representing a city. A cell in this grid is represented as (i,j), i.e. the cell at the i-th row and j-th column in the grid. You own two trucks A and B that deliver goods. Truck A is located at at (Ax,Ay) and Truck B is located at (Bx,By). Both trucks have an infinite number of goods. The two trucks could initially be at the same location. The distance to travel between cells (i1,j1) and (i2,j2) is the Manhattan Distance, i.e., |i1−i2|+|j1−j2| units. Your company has to serve N orders, where the i-th order is located at position (xi,yi). An order is said to be served if some truck moves to the location of the i-th order. Additionally, the i-th order can be served only once all order numbers from 1 to i−1 have been served.

EXPLANATION:

There are two trucks at (Ax,Ay) and (Bx,By) and N orders (Xi,Yi), each of these orders must be satisfied by either of these two truck (ie one of these trucks has to move to Xi,Yi to satisfy order i). The Trucks can only satisfy order i if all the orders before it are satisfied. The cost of satisfying an order is the Manhattan distance covered by the truck from its current position to reach the coordinates of that order. We have to find the minimum combined distance traveled by both trucks.

SOLUTION:

We can use Dynamic Programming to solve this problem. Let $n=N+2$, assume that we have n orders and consider the initial positions of the trucks as the first two orders.

dp[i][j] represents the minimum cost such that the first truck delivered its last order at $i{th}$ coordinate and second truck delivered its last order at $j{th}$ coordinate. So dp[0][1]=0 (The coordinates are numbered from 0 to n-1)

Now we can find the minimum cost by iterating over the orders from $2^{nd}$ coordinate to $n-1^{th}$ coordinate.

There are two cases:

1) The truck delivering $i^{th}$ order delivered also delivered $i-1^{th}$ order the other truck can deliver its last order at coordinates from 0 to i-2

dp[i][j]=dp[i-1][j]+abs(x[i]-x[i-1])+abs(y[i]-y[i-1]); //truck 1 moved from i-1 th to i th coordinate

dp[j][i]=dp[j][i-1]+abs(x[i]-x[i-1])+abs(y[i]-y[i-1]); //truck 2 moved from i-1 th to i th coordinate

(j=0 to i-2)

2) If $i-1^{th}$ order is delivered by the other truck then the truck delivering $i^{th}$ order can deliver its last order at coordinates from 0 to i-2

dp[i][j]=min(dp[i][j],dp[k][j]+abs(x[i]-x[k])+abs(y[i]-y[k])); // truck 1 moved from kth coordinate to ith coordinate

dp[j][i]=min(dp[j][i],dp[j][k]+abs(x[i]-x[k])+abs(y[i]-y[k])); // truck 2 moved from kth coordinate to ith coordinate

(j=i-1, k=0 to i-2)

The Final answer is the minimum of dp[n-1][i] and dp[i][n-i] (i=0 to n-2).

TIME COMPLEXITY

For each i, j goes from 0 to i-2 and k goes from 0 to i-2. The value of i goes from 2 to n-1. The time complexity of calculating dp will be $2*((N+1)*N/2)$. The final answer can be found out in linear time. Therefore overall time complexity will be $O(N^2)$.

SOLUTIONS LINKS:

Author's solution can be found here.
Tester's solution can be found here.
Editorialist's solution can be found here.

TRGR - Editorial

$
0
0

PROBLEM LINK:

PracticeContest

Author:Abhijeet JhaTester:Teja Vardhan ReddyEditorialist:Aswin Ashok

DIFFICULTY:

EASY

PREREQUISITES:

Union-find

PROBLEM:

A tree containing N nodes and rooted at node 1 is given. On each node of the tree, there is a monkey having information about a graph G. G is a graph containing N nodes. The information contained on each node is an edge of the graph G . Now for every node X, consider the path from root to X. You have to collect the information about edges from this path and construct a new graph G'. The constructed graph G' will be a sub-graph of graph G obviously. For each node you need to find the number of connected component in graph G'.

EXPLANATION:

Given a tree with N nodes rooted at 1. Each of the tree nodes contain an edge of a Graph G with also has N nodes. Each path in the tree gives some of the edges of the graph G and the graph formed by this is a sub-graph of G and let us call it G’. We are asked to find number of connected components in G’ (s) formed by all the paths from 1 to i (where i=1 to N).

SOLUTION:

Let us initialize the number of connected components in G’ as N, let’s call it cc. We can do a DFS from the node 1 of the tree. As and when we reach a node i we can check if the edge contained in the node connects two disjoint components in G’ using Union Disjoint Find. If yes we can reduce cc and store the answer for path 1 to i in answer[i] and store the roots of nodes in the edge and do union operation.

When the DFS retraces back we can use the stored to roots to see if the union operation at that particular node reduced cc. If yes we can undo the union operation.

Once the DFS completes get we the required answers.

TIME COMPLEXITY

Using Union Disjoint Find we can find the roots in $O(logN)$ and do union or undo it in $O(1$). There are N nodes in the tree so Overall time complexity is $O(NlogN)$.

SOLUTIONS LINKS:

Author's solution can be found here.

Tester's solution can be found here.

Editorialist's solution can be found here.

CRICSCR - Editorial

$
0
0

PROBLEM LINK:

Practice Contest

Author:Aswin AshokTester:Mayank PugaliaEditorialist:Mayank Pugalia

DIFFICULTY:

CAKE WALK

PREREQUISITES:

NONE

PROBLEM:

In this question we were given the score card (The Score and number of fallen Wickets) of a cricket match at N moments and we had to check whether the order of the given scores was possible or not. i.e. whether the recordings of the score done by Teja were correct or not.

SOLUTION:

We have to take care that the score at a particular moment is never strictly less that the previous moment and the same with the wickets, also we had to make sure Teja never read two or more scores where the wickets fallen were equal to 10.

So after taking the input we can compare the Score at moment i with i-1 for i>1 using simple if-else conditions.

If all the given scores are in order then we print YES otherwise NO

TIME COMPLEXITY:

We can do the score checking in O(N) as we only need to iterate through the score cards once.

SOLUTIONS LINKS:

Author's solution can be found here.

Tester's solution can be found here.

PREFNEC - Editorial

$
0
0

PROBLEM LINK:

Practice

Author:Mayank PugaliaTester:Aswin AshokEditorialist:Mayank Pugalia

DIFFICULTY:

EASY

PREREQUISITES:

NONE

PROBLEM:

Here we had to answer Q queries, i.e. Minimum cost of making a Necklace using exactly X beads and achieving exactly Y beauty value.

We can make a necklace using any of the 5 beads, each of them having its own beauty value.

S-> -2, G-> -1, Q-> 0, R-> 1 & D-> 2 and each of them had a cost. For every query we have to output the minimum cost of making such a necklace.

EXPLANATION:

If we used complete Brute Force then it would give a TLE, But if we used appropriate “Breaks” at correct places along with memoization then we could do it in the given time limit.(Basically being greedy)

The constraints of X and Y were set low because a improved brute with memoization was expected to pass.

INTENDED SOLUTION:

Using Brute:

->We try to calculate all possible necklaces and store the Min cost for each type.

->we need 5 nested loops running from 0 to 100, lets say that we used the variables i,j,k,l,m for the loops where i,j,k,l,m are number of beads.

->we calculate the beauty (Y) and the cost(C) of the making this necklace with (X=i+j+k+l+m) beads so we would store the cost of making this necklace using X beads and Y beauty.

cost[X][Y] = Min ( cost[X][Y] , C )

->now the beauty could go negative! (Max -200) so we would add an offset 200 to the beauty so that Y never goes negative so the dimensions of the “cost” array should be cost[101][401]

for example if beauty is -100 and beads are 50 we would use location

cost[ -100+offset(200) ][ 50 ] == cost[100][50]

After calculation of all the minimum cost we can answer the query in O(1) but the pre calculation would take time around O(10^10).

The thing to notice here is that we do not require all the iterations of the five loops because we know the the sum of the beads never cross 100 but in our brute we will calculate the cost for up to 500 beads so when ever the total number of beads becomes more that 100 we break from the respective loop

for(i from 0 to 100)

   for(j from 0 to 100)

      if(i+j greater than 100)

        break

      for(k from 0 to 100)

         if(i+j+k greater than 100)

         break

         for(...
     ...

    if(i+j+k+l greater than 100)

    break

    for(..

    and so on.. for “m” also

TIME COMPLEXITY

After doing this optimization the complexity for the precalculation comes around O(10^8) which will fit in time limit.

ALTERNATIVE SOLUTION:

Another solution is also there and many of them have used this methods.

Here we would use Dynamic Programming, i.e. we would make use of the previous states.

Let dp[i][j] denote the cost of making a necklace of beauty j with i beads

Now we can arrive at a state dp[i][j] from 5 different previous states

those are

-> dp[i-1][j-2] and use a diamond with beauty +2 so no of beads = (i-1) +1 and beauty (j-2)+2

-> dp[i-1][j-1] and use a ruby with beauty +1 so no of beads = (i-1) +1 and beauty (j-1)+1

-> dp[i-1][j] and use a quarts with beauty 0 so no of beads = (i-1) +1 and beauty (j-0)+0

-> dp[i-1][j+1] and use a glass with beauty -1 so no of beads = (i-1) +1 and beauty (j+1)-1

-> dp[i-1][j+2] and use a stone with beauty -2 so no of beads = (i-1) +1 and beauty (j+2)-2

All the five states would arrive at dp[i][j] after using a appropriate bead. And we can store the minimum of these costs.The complexity of this solution will be around O(10^6)

SOLUTIONS LINKS:

Author's solution can be found here.

Tester's solution can be found here.


PALLIND - Editorial

$
0
0

PROBLEM LINK:

PracticeContest

Author:Vaibhav TulsyanTester:Aditya PaliwalEditorialist:Aswin Ashok

DIFFICULTY:

EASY

PREREQUISITES:

Expected Value

Modular Arithmetic

MMI

PROBLEM:

A short and concise description of the problem statement. Bob has a string (S), which is initially empty. In one operation, he can select a lowercase character (a-z) uniformly at random and appends it to S. He then evaluates whether S is a palindrome or not; if it is, he gets 1 point. Given that Bob performs N operations in total, find the expected no. of points Bob gets.

EXPLANATION:

Given an empty string, Bob randomly picks a character from ‘a’ to ‘z’ and appends to the string and every time he appends he checks if the resultant string is a palindrome, if yes he get one point for that append operation. Bob does n such append operations and we are asked to find the expected value of the total number of points he gets. We have to find the answer $modulo 10^9 + 7$.

SOLUTION:

It is the sum of expected number of palindromes of length $i$, for i=1 to n. We can get the probability of getting a palindrome of length i by fixing the first i/2 characters and let the second i/2 characters be the mirror image of the first. For example: A string of length 4 will be palindromic if we fix its first two characters and let the next two be the mirror of the first two and for a String of length 5 we can fix the first three characters and let the last two characters be the mirror of first two. This works out to be $26^{ceil (i/2)}/26^i$ which is $f(i)= 1/26^{floor(i/2)}$. This is because $ceil(i/2) + floor(i/2) = i$ (for all integers)

The final answer is $\sum_{i=1}^{i=n} f(i)$

This becomes: $1 + 1/26 + 1/26 + 1/26^2 + 1/26^2 + …..+1/26^{floor(n/2}$

We can notice same terms repeating so we can re write the series

$1 + 2(1/26 + 1/26^2 + 1/26^3 + . . . + 1/26^{floor(n/2)})$ if n is odd

$1 + 2(1/26 + 1/26^2 + 1/26^3 + . . . + 1/26^{floor(n/2)}) + 1/26^{(n/2)}$ if n is even

Since n is very large we cannot evaluate every term. We can notice that $(1/26 + 1/26^2 + .. )$ is in GP so we can use sum of GP formula and Modular Multiplicative inverse to get the final answer.

TIME COMPLEXITY

To find sum of GP we have to find Modular Multiplicative inverse of the denominator in the sum of GP formula, which can be found out using Modular Exponentiation and the time taken for it is $O(logn)$ and last term if n is even can also be found out it $O(logn)$, Multiplication and addition can be performed in $O(1)$ so it can be done in $O(logn)$. Since there are t cases per file the overall complexity is $O(tlogn)$.

SOLUTIONS LINK:

Tester's solution can be found here.

Editorialist's solution can be found here.

COINSM - Editorial

$
0
0

Problem Link:

Practice

Setter: saquib ul hassan

Difficulty: EASY-MEDIUM

Prerequisites: Array

Problem: length N initially filled with 0’s. Later he was given Q queries each with three parameters L, R & W where W is the weight that has to be added to each element of the array in the index range L to R (index is 1 based). And display the array after all Q operations

Quick Explanation: Perform two things in a single operation: 1- Add k-value to only lower_bound of a range. 2- Reduce upper_bound + 1 index by k-value.

After all operations, iterate over the array and do sum+=arr[i], and display the sum.

SOLUTION:

Setter

Time Complexity: Lets say m is the number of queries and n is the length of an array O(m + n)

Does Time limit exceeded or memory limit exceeded means our answer was correct?

$
0
0

Does time limit exceed means our answer was correct but time to run was more? I am getting time limit exceed error, Time to run shown as 1.01 seconds while under the question its shown as 1-2 seconds. Can someone explain?

How to get rid of getting NZEC error while submitting solution in java?

$
0
0

To all who are geting NZEC, try using this format in java:

import java.io.*;
import java.util.*;

public class Main
{
    public static void main(String[] args) throws IOException
    {
        try{
            //Your Solve
        }catch(Exception e){
            return;
        }
    }
}

How to deactivate codechef account

$
0
0

Hey, could someone know about how can I deactivate codechef account permanently or restart whole progress of codechef account because I want to start from begining, I sent a mail to admin but they are not replying.

SUSPEND those who are involved in multiple plagarism

$
0
0

@c6h12o6 has been involved in plagiarism multiple times.Like what happened @ista2000 and many others, my code was exactly copied by him and he submitted 6 hrs later,I accept that I also made mistake by not marking my code private in ideone (since it was just my second contest,i didn't know that code goes public in ideone). but the main problem is he was caught in plagiarism many times before DEC16(when I was caught),still he was not suspended and again he has got caught in plagiarism after that 4 times(JUNE17,MAY17,APRIL17,MARCH17) and still he is not suspended.

if no contest got caught in plagiarism=no of points on graph-no of contest in (problems solved) section which are rated

then no of contest he got caught in plagiarism is 21

my solution :http://www.codechef.com/viewsolution/12243180

his solution :http://www.codechef.com/viewsolution/12246119

His old rating in long challenges till FEB17(after which new rating system came):-6359(last before rank)old rating

his new rating and graph:c6h1206

please SUSPEND accounts like this.if possible restore rating for people affected by him

Wrongly Caught in plagiarism

$
0
0

Respected @admin,i just recieved an email telling that i was caught under plagiarism in FEB18 long challenge .

It was for the 10th sum,where i took the code from hackerrank as it was asked in some past contest of hackerrank.However i did mention it in my code the link of that website.I made 2 submissions the first in which i forgot to write the reference,however i immediately made the 2nd submission with reference written on top.

Submission page(u can see the timings of submission): https://www.codechef.com/FEB18/status/LUCASTH,vivek_1998299

First submission: https://www.codechef.com/viewsolution/17298007

Second submission(with reference written on top): https://www.codechef.com/viewsolution/17298093

I really love codechef and like to help the community ,please be fair with me and restore the ratings.

(And yeah the other person (who's code matched with me) is from allahbad ,there's no way i'll know him)

(I had email but didn't got any reply)

Thank you!!


Edit Comment [How ??]

$
0
0

@admin Please give me back my power to edit my comments. I'm unable to do so. Screenshot attached. Only 3 options available with me.

I cannot edit my comment here - https://discuss.codechef.com/questions/126366/damn-what-just-happened/126422

View Content

Update1 -

View Content

Update2 - On giving forum a search https://discuss.codechef.com/questions/94991/is-somebody-else-also-missing-the-edit-comment-button Same issue again. Sorry for new thread. Found this in Related questions section.

Invitation to CodeChef April Lunchtime 2018!

$
0
0

Hello Fellow Coders!

The month of April held a special significance in the programming world, with the ACM-ICPC World Finals crowning a new world champion. So how about you cap off this brilliant month with Chef’s next contest, the April Lunchtime 2018 and join your fellow programmers and enjoy the contest problems.

Joining me on the problem setting panel are:

  • Problem Setters, Editorialists and Russian Translators: gainullinildar (Ildar Gainullin), altruist_ (Denis Anischenko)
  • Problem Tester: kingofnumbers (Hasan Jaddouh)
  • Statement Verifier: xellos0 (Jakub Safin)
  • Mandarin Translator: huzecong (Hu Zecong)
  • Vietnamese Translator: VNOI Team

I hope you will enjoy solving them. Please give your feedback on the problem set in the comments below, after the contest.

Contest Details:

Time: 28th April 2018 (1930 hrs) to 28th April 2018 (2230 hrs). (Indian Standard Time — +5:30 GMT) — Check your timezone.

Contest link:https://www.codechef.com/LTIME59

Registration: You just need to have a CodeChef handle to participate. For all those, who are interested and do not have a CodeChef handle, are requested to register in order to participate.

Prizes: Top 10 performers in Global and Indian category will get CodeChef laddus, with which the winners can claim cool CodeChef goodies. Know more here: https://www.codechef.com/laddu. (For those who have not yet got their previous winning, please send an email to winners@codechef.com)

Good Luck!
Hope to see you participating!!
Happy Programming!!

100% attendance laddus

$
0
0

Has anyone received the laddus for 100% participation between March '17-Feb '18?

CHEFPAR- Editorial

$
0
0

PROBLEM LINK:

Div1
Div2
Practice

Setter-Misha Chorniy
Tester-Misha Chorniy
Editorialist-Abhishek Pandey

DIFFICULTY:

CHALLENGE

PRE-REQUISITES:

Varying. Challenge problem is usually an application of your skills in competitive programming in general.

PROBLEM:

Given an array $A[]$ of randomly generated sequences, we have to add some integer $D_i$ (need not be distinct) to each array element $A_i$, where $0\le D_i\le K$. Our goal is to maximize $\frac{1}{M}\sum_{i=1}^{M} B_i$ where $B_i=(A_1*A_2...*A_N)\%P_i$

QUICK ANALYSIS:

It seemed that contestants faced problems in getting a good solution. We're concluding that, because, Some of the trivial solutions got too high points than what they should have got. Majority of the contestants simply printed back the input, or used $input+rand()\%K$ &etc.

ANALYSIS:

The first thing I want to say is that, this editorial is incomplete. And it will remain so, until you guys dont contribute! Its impossible to have any hard and fast approach for the challenge problems, and for the editorial to be at its full potential, I want to request you guys to discuss your approach. Benefit in challenge problem is better gained by discussion, seeing flaws of your approach and analyzing other's strengths- and seeing what worked well, and to what degree. Hence, I would request the community to put forward their approach and intuition behind the question :).

As for editorial, I will try to discuss some of the approaches I saw, in both div1 and div2. I hope you people like it :)

1. Div2-

Not even 10 minutes passed from start of contest on the historical date of $6th$ $April,2018$ when Div2 had got the first few accepted solutions. I had a guess in mind, and I,curious as a doomed cat, decided to see what they did and confirm my intuition. And I dont know if it was fate, or destiny, or perhaps something else, but what I saw was an exact picture of what I had in my mind...

cin>> arr[i]; //Take array input. cout<< arr[i];//Print it back.

This approach got something $\approx 85-88$ points. It was $88.7$ when I checked last on $14th$.
Further solutions were also on similar lines. Eg-

cin>>arr[i]; cout<< arr[i]+rand()%k;

This one got $85.8$ points then. Sad luck for that guy :/

cin>>arr[i]; cout<< arr[i]+k;

This solution performed better, and got around$88-89$ points on average.

Some of the better solutions at div2 which got $\ge90$ involved-

  1. Choose one of the primes. Lets call it $P$ Either largest, smallest, middle one or randomly any.
  2. Make array ideal according to that prime, i.e. add $D_i$ so that $(A_1*A_2..*A_N)\%P$ is maximum.
  3. Pray that this solution gets better points.

By roughly around 20-25 submissions, people experimented with what prime to take. Most of them settled on the median prime.

A good number of approaches used simulation and storing array and its result. Eg-

cin>>arr[i]; Store arr[i]+rand()%k;//Store in a vector etc. Compute score for the just stored array. Repeat above 250-400 times. Print the configuration with maximum score

Depending on luck and number of simulation, the above approach fetched $88-94.7$ points. I saw quite a few with $94.7$ points.

Some of the top approaches also use the concept of simulating till just about to time-out. The contestants chosed a distribution (random, or some other) which they simulated for $\approx3.8-3.95$ seconds where they sought to see which choice of $D_i$ is increasing score for a particular $A_i$. When about to time out, they aborted the process and printed the output they got.

2. Div1

The performance of Div1 was kind of similar to Div2 xD. One of the codes which got $91.1$ points at pretest was-

cin>>A[i]; cout<< A[i]+K/2;

Most of the approaches were common- like simulation till best answer, or take $rand()$ values $300-400$ times. Omitting the common approaches, the approaches of top solutions were quite distinct. (However, most of them are hard to decipher due to 300+ lines of code).

Some crucial optimizations were, however, seen. For example, lets say I got some values of $D_1,D_2...D_N$ and calculated the value of $Score=(A_1+D_1)*(A_2+D_2)*...*(A_N+D_N)\%P_i$. The top solutions preferred to change $D_i$ one by one, and re-calculate $Score$ in $O(Log(A_i+D_i))$ by using inverses as - $NewScore=({A_i+D_{old}})^{-1}*Score*(A_i+D_{new})\%P_i$. This method got $95+$ points on pretest.

Some of the good top codes deserve a mention here. These codes are what one can call crisp :)

  1. Python Code by @gorre_morre
  2. C++ by @anoxx_23
  3. C++ by @mihaibunget

As usual, I want to invite everybody (yes, everybody, not just the top scorers) to discuss their approaches so that we can have an engaging and learning insights into various intuitions :)

CHEF VIJJU'S CORNER:

1. The very first solution submitted by tester to test this problem was also simply printing back the input xD. After that as many as $16$ more submissions were made.

2.Lets discuss the setter's approach here. Lets take a random subset (serveral times) of array $P[]$ and multiply the primes in this subset. Lets call their multiple $MUL$. Now, we now that $MUL\%P_i=0$ where $P_i$ is a prime in the subset.Now, our aim is to get the value of $(A_1+D_1)*(A_2+D_2)....*(A_N+D_N)$ closer to (preferably exactly equal to) $MUL-x$. This is because, by applying $\%$ operation for various $P_i$, we will be left with $MUL\%P_i-x\%P_i=(-x)\%P_i$. We can go greedily and try to factorize $MUL-1,MUL-2,...,MUL-x$ (The exact value of $x$ can be experimented upon). The factorization will help us in manipulation of $D_i$ values.

One thing to check is that, $(A_1+K)*(A_2+K)..*(A_N+K)$ must have a value more than $MUL$ else the above scenario may not be possible. We can check this by using $log$ function, i.e. by changing expression $(A_1+K)*(A_2+K)..*(A_N+K)$
to-
$Log(A_1+K)+Log(A_2+K)+...+Log(A_N+K)$.

Similarly, $MUL$ can be expressed as $(Log(P_1) +Log(P_2)+....+Log(P_N))$

You can find good practice problem here

3.There is also a better random generator in C++ known as Mersenne Twister or mt19937. It is available from C++11 and later. Some of the advantages it has over rand() are that-

  • mt19937 has much longer period than that of rand. This means that it will take its random sequence much longer to repeat itself again.
  • It much better statistical behavior.
  • Several different random number generator engines can be initiated simultaneously with different seed, compared with the single “global” seed srand() provides

Accidental Submission of a code in a contest where I'm a problem setter

$
0
0

Hi I am a problem setter in May long challenge contest. I was trying to submit a solution to one of the problem through my campus.codechef.com ID and accidentally i submitted the solution in Long challenge contest page instead of Testing page. Now the verdict is showing on my codechef ID. My problem is featured in Div. 2 and I belong to Div. 1. as I'm part of the ranklist now, it may effect my rating. Please Help. Thanks

Viewing all 39796 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>