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

LECANDY - Editorial

$
0
0

PROBLEM LINKS:

Practice
Contest

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic knowledge of arrays and loops.

PROBLEM:

The program asks you to calculate if all the elephants would get the number of candies that they want.

EXPLANATION:

If there are C candies in all, and elephant i needs A[i] candies, then it is possible to serve all the elephants only if there are enough candies available, i.e. the following condition must be satisfied:

C >= A[0] + A[1] + ... + A[N-1]

This means you can have a simple loop over the array A to count the sum of the required number of candies by the elephants and then finally comparing it with C to determine the answer. If the above condition is satisfied, answer will be Yes, else the answer will be No (they have to be case-sensitive to avoid WA).

SETTER'S SOLUTION:

Can be found here.

APPROACH:

The problem setter used the above solution to solve the problem.

TESTER'S SOLUTION:

Can be found here.

APPROACH:

The problem tester used the above solution to solve the problem.


How do I win a CodeChef Goodie?

$
0
0

I want to know how can I get a CodeChef goodie? In which monthly contests, how many goodies are given? Does CodeChef also give certificates to the winners?

ALPHABET - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Sergey Kulik
Tester:Harshil Shah
Editorialist:Pawel Kacprzak

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Strings, Implementation

PROBLEM:

For a fixed set of Latin letters S, for each of given N words decide if it can be formed using only letters from S.

QUICK EXPLANATION:

For each of given words, check if all its letters are in the given set of known letters S by iterating over letters in S explicitly or using any data structure with fast lookup operation.

EXPLANATION:

Subtask 1


In the first subtask, the set S contains exactly one letter. In this case, it is very easy to decide if a given word can be formed using only letters from S, because there is only one letter that can be used, so for example if the letter in S is c, then all possible words that can be written using it are: c, cc, ccc, …. Since the length of any word in the input can be at most 12, then there are exactly 12 different words for which the answer is "Yes". For all other words the answer is “No”, because each of them contains at least one letter not in S.

Subtask 2


In the second subtask, S can contain at most 26 letters. In this case, for a given input word W, we want to check if all its letters are in S. In order to do that, we can iterate over all letters of W and for each one check if it is in S. Since S is very small, that check can be performed actually by iterating over all letters in S explicitly. The answer is “Yes” if all letters of W are in S, otherwise the answer is “No”. Thus, for a single word W, the answer can be computed in O(|W| * |S|) time, so the total running time is O(|total_len|*|S|), where total_len is the sum of lengths of all N words in the input.

For a faster solution, first we can store letters from S in any data structure that provides fast lookup - array will work the best here, since there are at most 26 different letters, but hash table is also fine here. If array is used this step building the array takes O(|S|) time. Then, for a given input word W, we can check if all of its letters are in S using the lookup in our data structure. It follows that the total running time of this method is O(|S|+|total_len|), where total_len is the sum of lengths of all N words in the input.

AUTHOR'S AND TESTER'S SOLUTIONS:


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

CS Academy Special Round #64 (Interactive only) with Prizes

$
0
0

Hi all,

I would like to invite you to CS Academy's next contest which takes place on Wednesday. The round will consist of interactive problems, only. There will be some money prizes awarded to the top 2 participants. You can find out more details on the contest page.

You are welcome to join. Good luck!

LAPIN - Editorial

$
0
0

Problem Link:

Practice
Contest

Difficulty:

Cakewalk

Pre-requisites:

ad-hoc

Problem:

Given a string S, if we split it in the middle (if S has an odd number of characters, disregard the middle character), then if the frequency of each character is the same in both halves, S is called a "lapindrome". Given the string S, test if it is a Lapindrome or not.

Explanation:

Maintain frequencies for the left half and the right half, for each character. After computing the frequency of each half, then check if the frequencies of all characters match. If so, output "YES", else output "NO".

Consider the following pseudocode: bool isLapin(S) initialize cntL[] and cntR[] with 0 L = S.length() for(i = 0; i < L/2; i++) cntL[S[i]-'a']++ for(i = (L+1)/2; i < L; i++) cntR[S[i]-'a']++ bool ret = true for(c = 0; c < 26; c++) if(cntL[c] != cntR[c]) ret = false return ret

The time complexity for this is O(|S| + 26) per test-case.

Setter's Solution:

Can be found here

Tester's Solution:

Can be found here

Android app for codechef with offline support

$
0
0

Fridge for Codechef

I just made a free open source android app, Fridge for Codechef, which is my first big project. Basically, during long challenges, I wanted to read the questions whenever I got free time. So this app was born out of desire to solve long challenge questions, in an interface which is mobile friendly.

So, this app allows you to download all the questions from a contest or directly download any particular problem, which can then be viewed as per your requirement. You can easily share your favorite questions and contests, and search for them. This app can associate itself with codechef links to directly open them inside the app.

This is the very first release. Do leave your ratings, reviews, feedback, opinions and feature requests.

Hope you enjoy it!

Edit: Now android 4.4 support has been added so if you have a phone with android kitkat you can also download the app

Edit 2: Now you can set reminder for upcoming contests straight from the contests list

Also do not forget to rate and share the app, if you like it

Play badge

Unofficial Editorials December Lunchtime

$
0
0

Hello Guys, I'm back with another set of editorials in hope you would like them. :)

I hadn't attended December Cook Off due to certain unavoidable circumstances, that's the reason of no editorials for Cook Off.

Without wasting much time, Here are the editorials.

Days in a Month

Difficulty: Cakewalk

Problem:

Given number of days in month and Day as on 1st of given month, Find out frequency of each day.

Solution:

Simplest solution use if else statements (Carefully though).

For W = 28, print 4 for each day, because a month with 28 days will always have 4 Sunday, 4 Monday ans so on.

For W = 29, print 4 for all days except the day of first of month. Example, for input 29 mon, ans is 5 4 4 4 4 4 4. (frequency of monday increased by 1).

For W = 30, print 4 for all days except the day of first of month and its next day. Example, for input 29 mon, ans is 5 5 4 4 4 4 4. (frequency of monday increased by 1).

For W = 31, print 4 for all days except the day of first of month and next two days. Example, for input 29 mon, ans is 5 5 5 4 4 4 4. (frequency of monday increased by 1).

For proof of above, You may consult Calendar. :D

Link to my Code

Strange Function

Difficulty:Easy

Problem:

Given A and N, compute $f(A^N)$, where $f(X)$ is defined as:

  • Compute the sum of digits of A; let's denote this sum by S.
  • If S is a single-digit integer, then F(A) = S.
  • Otherwise, F(A) = F(S).

Solution:

FIrst thing, make a function $f(X)$ as described above. Now, Notice that we need to calculate $f(ans)$ where ans = $A^N$, we can directly compute $f( (f(A))^N)$. Doing this avoids the issue of overflow.

Typical Modular exponentation Code (Refer geeksforgeeks) int power(int x, unsigned int y, int p) { int res = 1; // Initialize result

x = x % p;  // Update x if it is more than or
            // equal to p

while (y > 0)
{
    // If y is odd, multiply x with result
    if (y & 1){
        res = (res*x);
        if(res>=p)res = res%p;
    }
    // y must be even now
    y = y>>1; // y = y/2
    x = (x*x) % p;
}
return res;

}

Now, our solution is similar to modular exponentation, with one change. In Modular exponentation, we take res = (res*x); if res >= p, res = res%p;

But in our solution, we take res = res*x; $if(res >= 10) res = f(res)$. This way, we are calculating $f(A^N)$ in the same manner as Modular exponentation.

That's all.

Reason this works, is that suppose we have A = 15, N = 2.

$f((9+6)^2) = f(6^2 + 9*(9+12)) = f(36 + 9*21)$

Now, notice that the term 9*21 will never affect the value of our function.

For further proof, Calculate $f(9*X + Y)$ for some values of X and Y. The answer will always be Y.

Link to my code

Too Much Sweetness

Difficulty: Easy-medium

Prerequisites: DP

Problem

Given two bags of sweets with p and q sweets respectively, Find out number of ways of eating Exactly N sweets, subject to conditions that

  1. ith bag cannot be opened more than Bi time.
  2. We cannot eat more than Si sweets in one step from ith bag.
  3. We need to choose bags alternatively.
  4. First bag can be either one.

Solution;

Usually for counting problems where we need to make choices and count the number of ways of some sequence, we use DP, taking all the variables affecting answer in dp state.

DP state for this problem has been defined as

  1. N = Number of sweets to be eaten.
  2. p = Number of sweets in Bag 1
  3. q = Number of sweets in Bag 2
  4. B1 = Number of times we can open Bag 1
  5. B2 = Number of times we can open Bag 2

Base Case if(N == 0) return 1; if (N < 0, )return 0.

DP recurrence

if(last == 1)dp[N][p][q][B1][B2][last] = Summation from i = 1 to i = min(q,S2)solve(N-i, p,q-i,B1,B2-1, 2);

if(last == 2)dp[N][p][q][B1][B2][last] = Summation from i = 1 to i = min(p,S1)solve(N-i, p-i,q,B1-1,B2, 1);

Now, see what;s going on.

In each recursive call, we eat i sweets from bag other than the last one, Reducing sweets to be eaten, also reducing Number of sweets in that bag, and reducing the max number of times of opening respective bag by one, Thus, meeting all conditions.

Also, we run loop from 1 to min(p, S1) and 1 to min(q,S2), to comply with the condition of max sweets at a single step.

Also, use map in place of arrays which may give TLE. we do not visit all states.

Further We can also reduce state variables from 6 to 5 by noticing that N = P - p + Q - q where P and Q are input values while p and q is the current state values. But is didn't use it ad still it works. :)

Here's the link to my code.

Hope you all like my editorials.

On an important note, For further contests, One of my friend (@soham1234) has agreed to write unofficial editorials similar to mine. I hope you would like them too as much as you all do like mine.

spoj gss1 tle


Priority Queue Questions !!!

$
0
0

Can anyone provide me links to some priority queue questions?

Help with Puchi and Luggage

$
0
0

I am trying to understand this problem: Puchi and luggage. I understand that it is using Inversion Count of merge sort. But here, in author's solution, I don't understand why the Frequency array is updated twice where as it should be updated only once during merging..

LEBOMBS - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

DIFFICULTY:

Cake walk

PREREQUISITES:

None

PROBLEM:

You're given an array of houses some of which have a bomb and others don't. These bombs will explode simultaneously and when bomb in ith house explodes, it destroys adjacent houses. Your task is to find out the number of houses which aren't destroyed.

QUICK EXPLANATION:

For every house check if it is destroyed or not.

DETAILED EXPLANATION:

There are two almost similar ways of solving this problem. Key idea is to find out for each house if it is destroyed or not. How do we check if ith house will be destroyed or not? It will be destroyed iff at least one of i-1, i and i+1th houses have a bomb. Just beware of the boundaries as first and last houses have only one adjacent house. So final solution is :

saved_count = 0
for i from 1 to N
    destroyed = false
    if( S[i] == '1') destroyed = true
    if( i > 1 and S[i-1] == '1') destroyed = true
    if( i < N and S[i+1] == '1') destroyed = true
    if( not destroyed)
        saved_count += 1
print saved_count

An alternative solution would be to move over houses with bombs and mark those houses that will explode.

bool will_be_destroyed [N]
fill( will_be_destroyed, false)

for i from 1 to N
    if S[i] == '1'
        will_be_destroyed[i] = true
        if(i > 1) will_be_destroyed[i-1] = true
        if(i < N) will_be_destroyed[i+1] = true

saved_count = 0
for i from 1 to N
    if(not will_be_destroyed[i])
        saved_count += 1

print saved_count

Both of these are O(N) solutions and very comfortably fit in time limit.

SETTER'S SOLUTION:

Will be uploaded soon.

TESTER'S SOLUTION:

Can be found here.

GOODBAD - Editorial

$
0
0

PROBLEM LINK:

Practice
Contest

Author:Praveen Dhinwa
Tester:Misha Chorniy
Editorialist:Animesh Fatehpuria

PROBLEM

You just received a message given by a string $s$. You don't know whether this message is sent by Chef or his brother. Also, the communication channel through which you received the message is erroneous and hence can flip a letter from uppercase to lowercase or vice versa. However, you know that this channel can make at most $k$ such flips.

Chef always sends messages to his friends in all small letters, whereas the little brother sends messages in all capital letters. Determine whether the message could have been sent only by Chef, only by the little brother, by both or by none.

EXPLANATION

Number of uppercase letters <= $k$ implies that it could have been Chef. This is because we can consider all the uppercase letters as "flips" made by the communication channel, which would imply that our original message comprised only of lowercase letters. Similarly, number of lowercase letters <= $k$ implies that it could have been Chef's brother. Here is the implementation in Python:

t = int(input()) for _ in range(t): (n, k) = list(map(int, input().split(' '))) s = input() chef = sum([1 for ch in s if ch >= 'A' and ch <= 'Z']) <= k brother = sum([1 for ch in s if ch >= 'a' and ch <= 'z']) <= k if (chef and brother): print("both") elif (chef): print("chef") elif (brother): print("brother") else: print("none")

AUTHOR'S AND TESTER'S SOLUTIONS:

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

Data Structures and Algorithms

$
0
0

Hi all, I need your help to make a list of most used data structures and algorithms along with their tutorials, implementation and some problems on them. It will be helpful to everyone in many ways. I request everyone to contribute to this list by providing links to tutorials, problems, etc. I will keep updating this list regularly.

  1. Binary Search :Tutorial, Problems, Tutorial, Implementation, Problem

  2. Quicksort :Tutorial, Implementation, Tutorial

  3. Merge Sort :Tutorial, Implementation, Tutorial

  4. Suffix Array :Tutorial, Tutorial, Implementation, Tutorial, Implementation, Problem, Problem

  5. Knuth-Morris-Pratt Algorithm (KMP) :Tutorial, Tutorial, Implementation, Tutorial, Problem

  6. Rabin-Karp Algorithm :Tutorial, Implementation, Tutorial, Problem, Problem

  7. Tries :Tutorial, Problems, Tutorial : I,II, Tutorial, Problem, Problem, Problem

  8. Depth First Traversal of a graph :Tutorial, Impelementation, Tutorial, Problems, Problem, Problem, Problem

  9. Breadth First Traversal of a graph :Tutorial, Impelementation, Tutorial, Problems, Problem, Problem, Problem, Flood Fill

  10. Dijkstra's Algorithm :Tutorial, Problems, Problem, Tutorial(greedy), Tutorial (with heap), Implementation, Problem, Problem

  11. Binary Indexed Tree :Tutorial, Problems, Tutorial, Original Paper, Tutorial, Tutorial, Problem, Problem,Problem, Problem, Problem, Problem, Problem

  12. Segment Tree (with lazy propagation) :Tutorial, Implementation, Tutorial, Tutorial, Problems, Implementation, Tutorial, Implementation and Various Uses, Persistent Segment Tree: I, II, problems same as BIT, Problem, Problem/HLD is used as well/

  13. Z algorithm :Tutorial, Problem, Tutorial, Tutorial, problems same as KMP.

  14. Floyd Warshall Algorithm :Tutorial, Implementation, Problem, Problem

  15. Sparse Table (LCP, RMQ) :Tutorial, Problems, Tutorial, Implementation(C++), Java implementation

  16. Heap / Priority Queue / Heapsort :Implementation, Explanation, Tutorial, Implementation, Problem, Chapter from CLRS

  17. Modular Multiplicative Inverse

  18. Binomial coefficients (nCr % M): Tutorial, Tutorial, Paper, Problem

  19. Suffix Automaton :Detailed Paper, Tutorial, Implementation (I), Tutorial, Implementation (II), Problem, Problem, Problem, Problem, Tutorial, Implementation

  20. Lowest Common Ancestor :Tutorial, Problems, Paper, Paper, Problem, Problem, Problem

  21. Counting Inversions :Divide and Conquer, Segment Tree, Fenwick Tree, Problem

  22. Euclid's Extended Algorithm

  23. Suffix Tree :Tutorial, Tutorial, Intro, Construction : I, II, Implementation, Implementation, Problem, Problem, Problem, Problem

  24. Dynamic Programming : Chapter from CLRS(essential), Tutorial, Problems, Problem, Problem, Problem, Problem, Tutorial, Problem, Problem, Problem, Longest Increasing Subsequence, Bitmask DP, Bitmask DP, Optimization, Problem, Problem, Problem, Problem, Problem, Problem, Problem, DP on Trees : I, II

  25. Basic Data Structures :Tutorial, Stack Implementation, Queue Implementation, Tutorial, Linked List Implementation

  26. Logarithmic Exponentiation

  27. Graphs :Definition, Representation, Definition, Representation, Problem, Problem

  28. Minimum Spanning Tree :Tutorial, Tutorial, Kruskal's Implementation, Prim's Implementation, Problem, Problem, Problem, Problem, Problem

  29. Efficient Prime Factorization

  30. Combinatorics :Tutorial, Problems, Problem, Tutorial

  31. Union Find/Disjoint Set :Tutorial, Tutorial, Problems, Problem, Problem, Problem

  32. Knapsack problem :Solution, Implementation

  33. Aho-Corasick String Matching Algorithm :Tutorial, Implementation, Problem, Problem, Problem, Problem

  34. Strongly Connected Components :Tutorial, Implementation, Tutorial, Problem, Problem, Problem

  35. Bellman Ford algorithm :Tutorial, Implementation, Tutorial, Implementation, Problem, Problem

  36. Heavy-light Decomposition :Tutorial, Problems, Tutorial, Implementation, Tutorial, Implementation, Implementation, Problem, Problem, Problem

  37. Convex Hull :Tutorial, Jarvis Algorithm Implementation, Tutorial with Graham scan, Tutorial, Implementation, Problem, Problem, Problem, Problem, Problem

  38. Line Intersection :Tutorial, Implementation, Tutorial, Problems

  39. Sieve of Erastothenes

  40. Interval Tree :Tutorial, Implementation, Problem, Problem, Problem, Problem, Problem, Problem, Tutorial

  41. Counting Sort

  42. Probabilities

  43. Matrix Exponentiation :Tutorial, Tutorial

  44. Network flow :(Max Flow)Tutorial : I,II, Max Flow(Ford-Fulkerson) Tutorial, Implementation, (Min Cut) Tutorial, Implementation, (Min Cost Flow)Tutorial : I,II,III, Dinic's Algorithm with Implementation, Max flow by Edmonds Karp with Implementation, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem

  45. K-d tree :Tutorial, Tutorial, Implementation, Problem

  46. Deque

  47. Binary Search Tree :Tutorial, Implementation, Searching and Insertion, Deletion

  48. Quick Select :Implementation, Implementation

  49. Treap/Cartesian Tree :Tutorial(detailed), Tutorial, Implementation, Uses and Problems, Problem, Problem

  50. Game Theory :Detailed Paper, Tutorial, Problems, Grundy Numbers, Tutorial with example problems - I,II,III,IV, Tutorial, Problems, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Problem, Nim

  51. STL (C++) :I,II, Crash Course

  52. Maximum Bipartite Matching

  53. Manacher's Algorithm :Implementation, Tutorial, Tutorial, Implementation, Tutorial, Implementation, Problem, Problem, Problem

  54. Miller-Rabin Primality Test : Code

  55. Stable Marriage Problem

  56. Hungarian Algorithm, Tutorial

  57. Sweep line Algorithm : I, II

  58. LCP :Tutorial, Implementation, Tutorial, Implementation

  59. Gaussian Elimination

  60. Pollard Rho Integer Factorization, problem

  61. Topological Sorting

  62. Detecting Cycles in a Graph : Directed - I, II Undirected : I

  63. Geometry : Basics, Tutorial

  64. Backtracking :N queens problem, Tug of War, Sudoku

  65. Eulerian and Hamiltonian Paths :Tutorial, Tutorial, (Eulerian Path and Cycle)Implementation, (Hamiltonian Cycle)Implementation

  66. Graph Coloring :Tutorial, Implementation

  67. Meet in the Middle :Tutorial, Implementation

  68. Arbitrary Precision Integer(BigInt), II

  69. Radix Sort, Bucket Sort

  70. Johnson's Algorithm :Tutorial, Tutorial, Implementation

  71. Maximal Matching in a General Graph :Blossom/Edmond's Algorithm, Implementation, Tutte Matrix, Problem

  72. Recursion : I,II, Towers of Hanoi with explanation

  73. Inclusion and Exclusion Principle : I, II

  74. Co-ordinate Compression

  75. Sqrt-Decomposition :Tutorial, Tutorial, Problem, Problem

  76. Link-Cut Tree :Tutorial, Wiki, Tutorial, Implementation, Problem, Problem, Problem, Problem

  77. Euler's Totient Function :Explanation, Implementation, Problems, Explanation, Problems

  78. Burnside Lemma :Tutorial, Tutorial, Problem

  79. Edit/Levenshtein Distance :Tutorial, Introduction, Tutorial, Problem, Problem

  80. Branch and Bound

  81. Math for Competitive Programming

  82. Mo's Algorithm : Tutorial and Problems

MINMAX2 - EDITORIAL

$
0
0

Minimum Maximum Partition

Problem Setter:Istasis Mishra

Problem Tester:Istasis Mishra

Editorialist:Taranpreet Singh

Problem:

Given two arrays P and Q of Size N and an integer K, Minimize AND maximize the cost of partitioning the range [1...N] into exactly K partitions, where cost of a partition is defined as $min(P[L...N])*max(Q[1...R])$.

Prerequisites:

Dynamic Programming - Convex Hull Optimization or Divide and Conquer Optimization(But don't worry, its not as hard as it sounds)

Solution:

Since We have cost of a partition defined as $min_{L \leq i \leq N}(P[i]) \times max_{1 \leq i \leq R}(Q[i])$, we can observe that min(P[L....N]) = min(P[L], P[L+1....N]) and max(Q[1...R]) = max(Q[1...L-1], Q[L]). This means that we can pre-calculate min(P[i..N]) as well as max(Q[1...i]) for 0<=i<=N-1.

Now, The most complicated part of this problem is that, both P and Q can also have negative values, implying that in case both min(P[L..N) and max(Q[1..R]) are negative, we may still have positive cost, thus, have to be considered for Maximum solution, otherwise if there were only positive values then there is a nice greedy solution to this.

Now, to get the correct solution that receives 36 points, there is a recurrence. Let us define a function $F$ such that $F(i, k) = \text{Making k partitions till i}$. Defining the states like this gives the clear recurrence that $F(i, k) = min_{1 \leq j \leq i}(F(j, k-1) + A[j] \times B[i])$ where A[j] is the pre-computed value of min of all P from j to N and B[i] is the max of all Q from i to N. Using this as DP, we see that we have to traverse for each i, j and k and this is an $O(N^2 \times K)$ solution and gives 36 points.

We need to optimize it, and for that, it would require us the knowledge of Convex Hull Optimization. As we can see the Dp is of the form $y = m \times x + c$.

Basically, Convex hull deals with a set of lines with slope m and y-intercept, arranged on basis of slope in a stack, Speeding up selection of j in above recurrence to O(logN) time by use of binary search, giving us a total runtime of O(N^2*logN) which will easily pass the Time Limit.

The dp optimization mentioned above is usually used once, but in our problem, we are going to maintain K hulls one for each layer of DP. As you can see, if we treat the DP as having K layers then each layer depends on the previous layer. Thus, we can see that for each k we have to calculate the answer from k-1 and then add all the calculated “lines” in the current iteration to the stack.

Also, we can see that for min we require the “slope” to be decreasing and to find the min we want the slope to be increasing. Even though, this problem can be solved using a dynamic convex hull, this could be overcome by changing the DP to be calculated from N to 1 instead of 1 to N and also changing what represents the slope and the $x$. For more details, refer to the setters implementation below.

Now, to incorporate negative values and also accommodate for equal slopes, changes are required to be made in bad function (Refer code of Acquire problem here.

Also, one of the user solved this problem using divide and Conquer optimization. Here's the link to submission.

PS:Sorry for delay, its kinda hard writing editorial for a problem you yourself haven't solved yet.

Setter's solution

C++ Implementation

Java Implementation

How to forward declare variables in Python

$
0
0

I would like to know how to forward declare variables in Python. I have attached a program here. Please if anyon e has time please look at it. It is a pizza ordering program. SGST and CGST are taxes in my country. I have added the taxes to the final price and it is printing the final price as well. But I want to print SGST & CGST individually ( CGST = SGST = 2.5% of final price ). Please help me if you know.

CGST = 0.025 SGST = 0.025

View Content

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;
        }
    }
}

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

$
0
0

Hello guys,

As you all are aware, many times there are genuine users who wish to ask a question, but dont have karma for it. They then, have to resort to means of either asking their question in other threads, or request someone to upvote them so they can ask a question.

As we have seen last month, some fake accounts were used in malpractices in discuss, and they also gained karma by "I want to ask a question" thing. Hence, now it is becoming increasingly difficult to differentiate between genuine users, and fake users.

This thread is my solution for it. Any user, with less than 3 karma who wants to ask a question is requested to ask it here, and if the question is upto standards (meaning it needs more than those "one line answers") then we (at least I ) will convert your "answer" here into a question.

In short, post your question here, and if its a good genuine question, it will get posted as a separate question by using "Convert to question" feature.

In case your question required only 1 line answers or such, we would comment it on your question.

You guys are requested to direct any such guy (who wants to ask a question) here and not "free-upvote" them, so that we can avoid any duplicate/irrelevant questions (as questions posted here would be verified first, before converting to question).

Note to @admin - We will require your active participation and help in events related to deletion of any spam content here. Also, since only admins are ones who could delete answers, it is requested that you keep an eye out on this thread.

With Regards

Vijju123

Invitation to ACM-ICPC Asia-Kharagpur Onsite Replay Contest

$
0
0

Hearty Greetings!

I invite you to participate in the ACM-ICPC Asia-Kharagpur Onsite Replay Contest, which will feature the same problem sets faced by contestants at the ICPC 2017 onsite regionals.

Contest Details:
Time: (Saturday) 13th January 2018 00:00 hrs — 14th January 02:00 hrs Indian Standard Time — +5:30 GMT) — Check your timezone.
Contest link:https://www.codechef.com/KGP17ROL
Registration: You need to have a team and a CodeChef handle to participate.
Team Registration Link: https://www.codechef.com/teams/register/KGP17ROL.

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

Good Luck!
Hope to see you participating!

INOI 2018 discussion

Need help with a point update and range query question

$
0
0

Given an array of 'N' integers, I need to perform two kinds of queries :

  1. Point update : U P : Arr[u] = P
  2. Given a L,R,P I need to find the smallest number in the range [L,R] that is greater than P.

There are 'Q' queries.

This question was in a Hiring challenge on Hackerearth (Challenge is over now) so I can't provide a link to the statement. I want to know if this problem can be solved with complexity better than Q*Log^2N

Viewing all 40121 articles
Browse latest View live


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