"I want to ask a question" - Ask them all here!

Can Anyone Provide links and resources to study all about trees, related algorithms and it’s corollaries, from a beginner level?

please someone explain how to solve his?

help me… it working on all the tests i tried but i always get WA! where am i wrong?
https://www.codechef.com/viewsolution/16606169

how can I enter two,three values in a single line in python.
For eg. if I want to enter value of x,y in such a way
INPUT:
2 3
I want to input 2 3 in x and y ina single line .
How can I do this ?
will map function help me ?

Codechef Newbie here,

Below is my code for the recent Cookoff 89. Problem Football Match. It passes the example case, but then gives Wrong Answer after I submit. What is the error in my code?


n = int(input())
team1 = ""
team1count = 0
team2 = ""
team2count = 0
scoreArr = []
 
for x in range(n):
    testcaseNumber = int(input())
    for y in range(testcaseNumber):
        scoreArr.append(input())
    for z in scoreArr:
        if team1 != "" and team2 != "":
            continue
        elif team1 == "":
            team1 = z
            team1count = scoreArr.count(z)
        elif team2 == "":
            team2 = z
            team2count = scoreArr.count(z)
    if team1count == team2count:
        print("Draw")
    elif team1count > team2count:
        print(team1)
    else:
        print(team2)
    team1 = ""
    team2 = ""
    team1count = 0
    team2count = 0
    scoreArr = []
   

Thanks so much!

Where can I ask competitive programming questions?

Sometimes I am not able to understand problems or editorials or want to know some other way to solve the problem.Stack overflow community downvotes these type of questions.So is there any other site where I can post my queries and get answers in reasonable time?

@vijju123 I have read your solution for CHEFXOR of December long challenge I understand you have used SQRT Decomposition(if i am not wrong) can you please explain it a bit , or add some comments to the code so that I could understand it better ?
PS : big fan keep up the good work :smiley:

I solved a problem in BITFLIT v0.2 code SUPGLRES, and gave this solution, which is a generalised solution to any ordering of the queue (not necessarily the pairs need to be together, i.e, a random pair can be defined). But it ran into NZEC error. I would be thankful to anyone who can check the code and rectify the mistake:

import java.io.*;

class bitflit3test

{

public static void main(String[] args)throws IOException

{

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int i,j,n;

long k;

String l;

n = Integer.parseInt(br.readLine());

long [] a = new long[n];

l = br.readLine();

for(i=0;i<n;i++)  a[i] = Long.parseLong(l.split(" ")[i]);

for(i=0;i<n;i++)

{

  for(j=i;j<n;j++)

  {

    if(a[i] < a[j])

    {

      k=a[i];

      a[i]=a[j];

      a[j]=k;

    }

  }

}

for(i=0;i<n;i++)

{

  for(j=0;j<n-1;j+=2)

  {

    if(a[j]==a[j+1])

    {

      if(j==0) {  k=a[1];a[1]=a[2];a[2]=k;}

      else {k=a[j-1];

      a[j-1]=a[j];

      a[j]=k;}

    }

  }

}

k=0;

if(n%2!=0)  k=-1;

else

{

  for(i=0;i<n-1;i+=2)

  {

    if(a[i]<=a[i+1])

    {

      k=-1; break;

    }

  }

}

if(k==-1) System.out.println(“No”);

else  System.out.println("Yes");

}

}

I have implemented a sieve of eratosthenes code with O(N) time complexity. I am getting a SIGABRT error.
terminate called after throwing an instance of ‘std::bad_alloc’
what(): std::bad_alloc

1.What is a SIGABRT error?

  1. What is the error made here?

  2. Suggest resources for learning C++ for Competitive coding. I know C and Java.

    #include <bits/stdc++.h>
    using namespace std;

     const long long MAX_SIZE = 1000000001;
     
     vector <long long >prime;
     vector <long long>isprime(MAX_SIZE,true);
     vector<long long>SPF(MAX_SIZE);
     void seive(int n){
         isprime[0]=false;
         isprime[1]=false;
         for(long i=2;i<n;i++){
             if(isprime[i]){
                 prime.push_back(i);
                 SPF[i]=i;
             }
             for(long j=0;i*prime[j]<n && j<(int)prime.size() && prime[j]<=SPF[i];j++){
                 isprime[i*prime[j]]=false;
                 SPF[i*prime[j]]=prime[j];
             }
             
         }
     }
     int main() {
         int t;
         scanf("%d",&t);
         seive(10000000);
         for(int i=0;i<prime.size();i++)
         printf("%d\n",prime[i]);
         return 0;
     }
    

Thank You

Wrong Editorial link
Hey @vijju123, @admin,
The editorial link for the problem BWCELL, CodeChef: Practical coding for everyone and BWCELL Problem - CodeChef is wrong. It should be BWCELL - Editorial - editorial - CodeChef Discuss .

@vijju123 please help

I have recently signed up on codechef(1 week around) and I have secured 4th rank in Schools in India.But unfortunately, my school is not listed on Codechef so I want to know that if I am eligible for laddus of this contest or not.

I would also request @admin to add my school to list asap and I am all ready to help them in this regard.

Here is the link to my school official website.

In the December Lunchtime yesterday, I looked in the ranklist after solving two problems and to my surprise I was ranked 11’th overall with 200 points. (I saved a screenshot! haha).

Then a few minutes later I looked at the ranklist again and my rank was down to 100, but there were now many more people ranked higher than me who also had only 200 points.

Was this a glitch or some kind of timing issue? The contest said “IOI Scoring rules” which said ties were broken by shortest time to reaching a particular score. So if at one time I had rank 11 with score 200, how could I later be ranked lower than people who also got 200? Thanks for any explanation.

Outdated Link

Hey @vijju123, @admin,

Although it is not a big issue, but still posting.:slight_smile:
The link (when clicked on ?), wmd-editor.com on the upper-right corner of the editor is outdated, it takes to a Japanese Health Website.

PS: This link, Daring Fireball: Markdown Syntax Documentation can be used for markdown help.

1 Like

if possible please provide a counter case : runtime error! - general - CodeChef Discuss

Code chef informs that any second account of my own which is not in use should be reported. I have an account for which I forgot the username. How do i inform codechef about it?

How to find Division and remainder of no if only operators available are addition and Subtraction?? PLs Help///\

A bit confused of what a humongous subsequence exactly is.Like if we take ‘10010’ then is {1,3} also a humongous subsequence, and how is {1,5} a humongous subsequence.
For ‘10010’ humongous subsequences should be {1,2},{4,5}, but these aren’t the only ones, {1,5},{1,3} also, and what about {1,2,4,5} and {1,3,4,5}???

Hello Vijju123 , I am a new programmer so i just want some tips how to imporve my basic programming because i have a lot of problem in finding the solution(The Logic),if i understand the logic of the program then its nothing , so my main problem is how shall i decode the logic of the program , please provide me with some of your important tips so that i may also become like u . Hope u would help me.

Why is ranklist showing 0 pts for all participants for the challenge sum of this long challenge?

In INOI, CodeChef gave us the access to some test cases, but they were too large to copy paste into the ide. Can anyone tell how to run input files in terminal?