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

CHEFPLAG - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Nikhil Ramakrishnan
Tester:Nikhil Ramakrishnan
Editorialist:R. Ramana

DIFFICULTY:

SIMPLE

PREREQUISITES:

Calculating percentages.

PROBLEM:

You are given the number of sentences $P$ and a list of numbers depicting the number of words that are same/plagiarized in the respective sentence. You are also given the minimum number of words $K$ that must be same in a sentence for the sentence to be considered as plagiarized.

QUICK EXPLANATION:

Check if the more than 40% of the integers are greater than $N$.

EXPLANATION:

To solve this question, we first flag which sentences are plagiarized, to do this we check the number of common words in each sentence and compare it with the minimum number of allowed common words, $K$.

If we represent the number of common words in a sentence as $n[1], n[2], n[3], ..., n[P]$ then we check if $n[j] >= K$ for $j$ in $[1, P]$.
If $n[j]$ comes out to be more than or equal to $K$ then the sentence is considered to be plagiarized.

Let us represent the number of plagiarized sentences by $PlagNumber$ and initialize it to $0$. Now whenever we encounter a plagiarized sentence we will increment $PlagNumber$ by one.

Once we have the total number of plagiarized sentences $(PlagNumber)$ for the case, we calculate the plagiarism percentage (say $PlagPercentage$) by dividing the total number of plagiarized sentences $PlagNumber$ with the total number of sentences $P$ and then multiplying the result with $100$.

Finally we check if the plagiarism percentage is more than $40%$, if so we give the output as FAIL otherwise the output will be PASS.

An algorithm for this would look something like this:

PlagNumber = 0

for (i = 1 to P)
{
   if (n[i] >= K)
   {
      PlagNumber = PlagNumber + 1
   }
}

PlagPrecentage = (PlagNumber/P) * 100

if ( PlagPercentage > 40)
{
   Output("FAIL")
}
else
{
   Output("PASS")
}

Time Complexity

$O(N)$

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution


Viewing all articles
Browse latest Browse all 39796

Trending Articles



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