Wrongly Penalized in Codechef starters 170
Dear Codechef,
The problem you have sent for plagiarism was done by me and i have not shared it at any place and i have used generative ai to restructure (for removing useless variables) the code as i do it on my ide first, then i paste it on codechef compiler ,whenever i am not finding correct logic because its fast to debug your code on your compiler. I use my offline compiler named as intellij idea. I wont share code at any place. As this problem’s solution is simpler because we just have to count number of even and odd number of elements.So, possibly my solution collided with someone else’s solution and we got plagiarized. I had solved these kind of Adhoc problems many times in previous contests.
You may check my history of solving problems. you may also check my previous submissions of this problem in which i followed different approaches to come to my final approach.
1st approach, passed two test case files (i passed sample test cases with this code)
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
int n = sc.nextInt();
int arr[] = new int[n];
for(int i = 0; i<n; i++){
arr[i] = sc.nextInt();
}
int ans = (n+1)/2;
System.out.println(ans);
}
}
}
2nd approach, only passed sample test cases
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0){
int n = sc.nextInt();
int arr[] = new int[n];
for(int i = 0; i<n; i++){
arr[i] = sc.nextInt();
}
int numT = 1;
int ryt = 1;
int lft = 1;
for(int i = 1; i<n-1; i++){
int left = Math.abs(arr[i]-arr[i-1]);
int right = Math.abs(arr[i]-arr[i+1]);
if(left > right ){
ryt++;
}else{
lft++;
}
}
int ans = Math.max(ryt,lft);
System.out.println(ans);
}
}
}
// 16
//
3rd approach, final solution (which was plagiarized)
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main(String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt(); // Number of test cases
while (t--> 0) {
int n = sc.nextInt(); // Number of elements
int odd = 0, even = 0;
for (int i = 0; i < n; ++i) {
int x = sc.nextInt();
if (x % 2 == 0) {
even++;
} else {
odd++;
}
}
System.out.println(Math.max(odd, even));
}
sc.close();
}
}
// 2 3 6
//. 6 4 3
you may see in all aproaches, i am just trying to build logic to count some elements for answering the problem
Only the counting logic is changing in every approach.
Now, i am attaching the code i coded on my intellij Idea
Code on my IDE
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t--> 0) {
int n = sc.nextInt();
int arr[] = new int[n];
for (int i = 0; i < n; ++i) {
arr[i] = sc.nextInt();
}
int odd = 0, even = 0;
for (int i = 0; i<n; i++){
int x = arr[i];
if (x % 2 == 0){
even++;
} else {
odd++;
}
}
System.out.println(Math.max(odd, even));
}
}
}
Code of generative Ai (it removed the initialization of Array because we simply take x as input and check whether it is even or odd and closed the scanner)
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main(String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt(); // Number of test cases
while (t--> 0) {
int n = sc.nextInt(); // Number of elements
int odd = 0, even = 0;
for (int i = 0; i < n; ++i) {
int x = sc.nextInt();
if (x % 2 == 0) {
even++;
} else {
odd++;
}
}
System.out.println(Math.max(odd, even));
}
sc.close();
}
}
// 2 3 6
//. 6 4 3
From codechef, code of conduct
point 7
Taking help or using third party code is not bad. Passing it off as your own is. If you are taking your code from some other source, it is expected that you give the due attribution to the source in your code. It is mandatory. The third party code should have been available publicly before the relevant contest began, and not created during the contest. And if questioned, the proof of burden rests on you to prove this beyond a doubt.
But in case you have missed giving attribution to a third party code, and you get caught in our plagiarism check, then you have the option of proving to us that this was indeed a publicly available code.
So, this code is available on internet and more commmonly it is basic code for counting even and odd elements.
Rules on generative Ai usage:
point 2
Permitted Usage: You may use generative AI to derive standard functions, such as sorting algorithms or mathematical computations, that do not directly solve the problem.
So, I used generative ai to calculate even and odd elements effectively by removing unusable stuff.
I kindly request you to reconsider my case and review my solutions once again. The logic for solving this problem is straightforward, and it is highly likely for solutions to overlap as there are limited ways to count even and odd elements (while some bitwise operations exist, most people rely on this commonly used approach for such problems). Marking this as plagiarism could be demotivating for me, especially when solving problems with simple logic like this. I sincerely hope for a fair reassessment of my work.
Thanks for considering,
Your coder
shameerr