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

solution to question, that how to reverse the string from any point, in java

$
0
0

To print any type of string in this order example " My Name Is" output should be in this format " yM emaN sI" every word in the string has to be reversed individually.


Invitation to ICO practice contest 1

$
0
0

Hello, everyone. I would like to invite you to the first contest of the ICO prep series.

Problem Setters: Udit Sanghi, Shashwat Goel, Istasis Mishra
Problem Tester: Udit Sanghi
Editorialist: Shashwat Goel

It will be held on 13th October from 8:00 pm to 11:00 pm IST. Link - Contest

The contest will be unrated. Hope you like the problems. There would be 4 problems and 3 hours to them. The problems difficulty would be around CF Div2 B-C-C-D.

Also, the editorials will be published soon.

Please ask your doubts below.

CHMOD - Editorial

$
0
0

PROBLEM LINKS

Practice
Contest

DIFFICULTY

EASY

PREREQUISITES

Simple Math, Repeated Squaring

PROBLEM

You are given a list of N integers.

Each value in the list is between 1 and 100.

You have to respond to T queries of the following type

  • Given L and R
  • Find the product of all integers in the given list between L and R, inclusive
  • Find the above product modulo some M, which is also given

EXPLANATION

For each query, iterating through the list between L and R to maintain the modular products is too slow.

Of course, we use the fact that each value is between 1 and 100 to our advantage.

  • There are 25 prime numbers between 1 and 100

Each number has a unique prime factorization. The product of a set of numbers can also be simulated by adding up the frequencies of each prime in all numbers in the set.

For example, suppose we have to multiply 36 and 45.

36 = 2232
45 = 325

36 * 45 = 22345

Thus, we can maintain a table of cumulative frequencies for each of the 25 primes between 1 to 100 for the given list of numbers.

When processing a query

  • consider each of the 25 primes
  • find the frquency of the prime between L and R. This can be done in O(1) using pre-calculation of cumulative frequencies
  • calculate primefrquency for each prime and multiply these values
  • maintain the result modulo M

These ideas are best presented in the pseudo code below.

PSEUDO CODE

Given:
    N, the number of numbers
    L[N], the list of numbers
    P[25], primes between [1, 100]
    CF[N,25], cumulative frquency for each prime

for each query Given Query: left, right, M answer = 1 for i = 1 to 25 r = CF[right,i] - CF[left-1,i] v = P[i]r % M, use repeated squaring answer = (answer * v) % M

The complexity of answering each query would be O(25 log N).

Cumulative Frequencies can be calculated in O(25 * N).

CODING COMMENTARY

You can either calculate the primes in thr porgram or hard code the array of primes by calculating it offline.

The repeated squaring should take care of the fact that the exponent can be 0. a0 should return 1 for any a.

Calculating the cumulative frequencies table should be done carefully. The frequencies of the primes for each number between 1 and 100 can be pre-calculated. Use these frequencies to build the cumulative frequencies table.

SETTER'S SOLUTION

Can be found here.

TESTER'S SOLUTION

Can be found here.

Is there any option to check for exactly which testcase our programs is giving wrong answer.?

$
0
0

I am new to programming on CODECHEF. I am experiencing this problem in which my program runs perfectly for the given test cases in questions but says wrong answer while submitting. I want to know is there any way to find out for exactly which test case my program is failing?

Ratings for Institutes In Competetive Programming (CpCtrl.com)

$
0
0

Hello Everyone,

Codechef has been a great platform for motivating and guiding potential competitive programmers on the individual basis. Ratings for all the contests: Long, Short and Lunchtime keep the sense of competition ongoing.

To provide and promote competition on the institution level, I designed a rating list provides unofficial ratings for all institutes ln the basis of Long contests of Codechef. Check it here.

The rating system works on the basis of ELO rating system. For more information about the entire rating system, please check this.

This rating system is entirely unofficial but does motivate the performance on institute level.

Future Additions to the Website:

  • Rating System for Short and Lunchtime challenges.
  • Full Event description regarding total participants and submissions grouped into colleges.

Any more inputs would be most welcomed from all programmers to improve this platform.I hope you all like it.

Edit- Now you can check ratings for cook-off events also.

Doubt regarding ACM ICPC Regionals

$
0
0

Is it possible to change site for ACM ICPC regionals? My team has been registered by the coach but still we have not paid onsite fees.

submission info not found while submitting problems in practise session

$
0
0

I have submitted the same solution given herein on of the editorial(https://discuss.codechef.com/questions/110979/unofficial-editorial-seaco-and-fill-matrix-briefly), but it doesn't show submission info when I submit it?

Here is the link to the same where I submitted (https://www.codechef.com/viewsolution/15470300 ) This is because if I don't get submission info, how can I get to know whether I got partial marks or not? Here is another submission I found where the submission got partial marks (https://www.codechef.com/viewsolution/15418126 ).

Your Best Rank In Codechef ..!!

$
0
0

Just as codechef shows our highest rating on codechef ,similarly our best rank sholud also be displayed there.


Invitation to KJSCE CodeSpree 2017

$
0
0

KJSCE Codecell presents CodeSpree, with CodeChef as Programming Partner.

Contest will last for 3 hours. It will be an ACM-ICPC style contest. It will start on 1st October 2017 at 21:00 hours IST.

Anyone can participate in this contest. This is a part of Abhiyantriki, technical fest of KJSCE.

Prizes worth 2000/- and laddus are up for grabs.

Contest link is https://www.codechef.com/KJCS17

You can register here.

Join the Facebook page here.

P.S:-Only Indian participants are eligible for cash prizes or to get selected for the onsite round.

Update

The contest is over the winner will get a mail soon. If you haven't registered and were among the top participants please fill the google form above so that we can contact you. Thank you all for participating.

swapping two characters in python string ?

$
0
0

what is the easiest way to swap two characters in a python string ?

A few questions about ZCO 2017

$
0
0

This year I am participating in ZCO 2017 so I have a few questions related to it, it would be a really big help if anyone could help me out. My questions are:

  • How many question come in ZCO?
  • What is the requirement to qualify for the next level?
  • What is the time limit for ZCO?

Once again thank you.

write a program to generate unique substrings(contains only unique characters) of given string.

$
0
0

please suggest efficient algorithm

Getting started here, questions about strategy, etiquitte, etc.

$
0
0

Hi guys.

I've just started here, I have a few questions about how I approach this place. Firstly, let me just say that wow - some of the problems here are pretty difficult, even for easy!

Alright, so I've just bunch of the questions in the FAQ, here's a few more.

  1. What's the etiquette for posting here? For example are 'I'm working XYZ practice problem, I've got TLE error, here's my code, what should I do?' questions ok?

  2. What's the general strategy for solving problem, or doing time optimization? Are there any tools that you use? Like, one of the things I can see that would be problematic, is when you get a 'wrong answer' but you don't know what the 'expected vs output' is. Is this just something you need to deal with as a programmer, to think of the corner cases yourself?

  3. Is there any way to get additional test data?

  4. How do you organise your code chef files in your IDE? For example, your class name (in Java) must called Main, and it can't be part of any package, when you paste in to the submitter, otherwise it'll give you an error, wondering how people deal with that.

  5. code reusablity - I get the feeling that a lot of this is going to be using various appropriate algorithms. What I would tend to do is import the package that contains the algorithm. But given that the submission has to be a single file with no non-native imports, is the only thing you can do, is copy the code in for each algorithm?

  6. Where would you start in terms of first problems to solve? For example I would suggest doing the Enormous Input test as one of your first problems.

.

BINARY TREE

$
0
0

explain about binary tree concept

stack data structure

$
0
0

Difference between stack and queue


tree search

$
0
0

difference between linear search and binary search ?

binary search

$
0
0

why we are study binary search give some uses

binary search

$
0
0

Explain about binary search tree

difference between c++ and c++14 ??

$
0
0

what is the difference between c++ and c++14 ????

Invitation for ICO Preparatory Series

$
0
0

Hello everyone!

As you might know, the first stage of the Indian Computing Olympiad, the Zonal Computing Olympiad is approaching. Leading to the most prestigious programming competition for school students, IOI to be held in Tokyo, Japan next year. ZCO is to be held on 11th of November, 2017. For more information see the poster below or click here.




I'd like to invite everyone to a series of preparatory contests for the upcoming ZCO/ZIO and INOI. It will consist of short fun unrated contests which will be aimed for school students for preparation for the ZCO/ZIO and INOI. Nevertheless, it will also be beneficial for college students as ICPC is coming up. The contests are unrated.

Details about the series:

  • Contest will take place every friday starting from 13th of October.
  • Further details about each contest will be given as a blog post before each contest by the contest admin.
  • Each contest will consist of 4 problems.
  • Duration: 3 hours
  • Scoring system: IOI style
  • Difficulty will range from ZCO level to INOI level. That is equivalent to easy-medium in codechef terms. Problems might even have a hard subtask.
Problems would be set by:
1. Istasis ista2000 Mishra
2. Udit mathecodician Sanghi
3. Shashwat harrycoda Goel
4. Tanavya sinbycos Dimri
5. Rajarshi rajarshi_basu Basu
6. Vatsal vatsalsharma_3 Sharma
7. Swetanjal swetanjal Datta and
8. Yogesh yogesh01 Aggarwal


NOTE: In each contest only two of the setters will be involved and we wont discuss problems among ourselves so the other 6 of the setters may also participate.

You can ask for help regarding problems and discuss problems in this thread or in the contest announcement thread(which will be out later).

Also, please do tell us what do you think about this initiative in the comments. Any suggestions/feedback will be appreciated.

Hope you have a great time solving problems in the contests. :)

Viewing all 40121 articles
Browse latest View live


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