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

A big bug in Rating system..!!!

$
0
0

Here,

  • It is my rating graph for Jan Long Challenge 2019(Div.2),And see my rating inc. by 14.So which becomes 1581.
  • And my Rank was 2673.

My Graph

  • And this is Another graph of the person from same rank list,which is inc.by +26,which becomes 1590.
  • And his rank was 3990.

His graph

And,My rank was more than him,but his rating inc.by +26,but mine was +14...Give me reason @admin@vijju123 Thank you..!!!


A doubt in approach of MAXEP problem ( Shared by IOI Gold Medalist ) - December long contest 2018

$
0
0

I wrote an editorial regarding how to solve the MAXEP problem asked in december long contest 2018.

A lot of users shared wonderful approaches to take on the problem (besides my way of solving it), but I was not able to understand the approach of @utaha.

So any-one who understands how @utaha solved that particular problem - Please help...!!!

Especially I would be glad if @utaha himself helps me...!!!

That approach was ( as @utaha mentioned in the editorial ) from an IOI gold medalist and sounded very simple, just the fact was that I was not able to understand why was it working...

Link to that editorial can be found HERE

I asked my doubts there in the comments section ( Just under where @utaha shared his approach), but I guess no one is looking at that editorial now... So I decided to ask it seperately here.

But if you get @utaha's approach, Please share it in that editorial itself. ( It will be good for me to have all material of one question under one link itself)

Thanks in Advance...!!!

FANCY - EDITORIAL

$
0
0

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2

Setter:Shivam Gupta
Tester:Xiuhan Wang
Editorialist:Taranpreet Singh

DIFFICULTY:

Cakewalk

PREREQUISITES:

None

PROBLEM:

Given a string, check if it contains the word "not" as a complete word. (Not as a part of another word, like nothing)

SUPER QUICK EXPLANATION

  • The quote is Real Fancy, if the quote is "not", quote begin with "not", quote ends with "not" or quote contains "not" where "*" represents space character.

EXPLANATION

Consider the special case where quote itself is "not" separately.

After this, the word "not" can either appear as the prefix, as the suffix or in between the quote. So, check separately if the first word is "not", the last word is "not" or the quote contains the word "not". (Make sure to check that the word "not" is surrounded by space character on both sides.)

Trick

Those not interested in splitting the string into words can solve this by inputting the quote as a string, add space character at both ends of strings. Now, the quote will be "Real Fancy" if it contains "not" where "*" represents space character.

As a side fact, @vijju123 actually have a thing about fancy quotes. He has another fancy quote, shared during the contest, "You made my non-fancy quote a fancy one".

Time Complexity

Time complexity is $O(|S|)$ per test case where $|S|$ is the length of the quote.

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution
Editorialist's solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :)

A very big plagiarism this long challenge JAN19.

$
0
0

Codechef did not do his job this long challenge yet it was obvious that the plagiarism had to be very big. Out of 10 solutions in python3.6 I count 4plagiarisms on XYPIZQ.

And what disgusts me is that the scores of all these cheats have been calculated. Some of them were just copying and others using other techniques that I prefer not to say here so that others do not use it.

This attitude was common in India and I find it very sad to behave when I see all the work done by codechef, geeksforgeeks and ... This is not the way that India will stand out as a respected power. Please stop the plagiarism because I know people who prefer not to participate because of it. Even his ranking backward gradually because of the people who cheat is frustrating.

Look at these solutions:https://www.codechef.com/viewsolution/22482771https://www.codechef.com/viewsolution/22482425https://www.codechef.com/viewsolution/22483248https://www.codechef.com/viewsolution/22482660

Just in one page.

And this is about all the problems of competition

Pizza Slice (XYPIZQ) mini editorial

$
0
0

Consider this diagram. Half of the line segments are drawn in red. The line segments $a_0b_1,b_1a_2,a_2b_3,b_3a_4$ also exist, but are ommited here for clarity.

alt text

We do not yet know what angle $x$ is, but we can work out the other angles in terms of $x$. We will be working in radians here. $\pi\ radians = 180\ degrees$

Because the slice is an isosceles triangle, we can calculate:

$c = \frac{\pi-x}{2} = 0.5\pi - 0.5x$

Knowing that all the inner triangles are also isosceles trangles, we can also calculate:

$d = \pi - 2c = x$

$e = c - d = 0.5\pi - 1.5x$

$f = \pi - 2e = 3x$

$g = \pi - c - f = 0.5\pi -2.5x$

$h = \pi - 2g = 5x$

$i = \pi - e - h = 0.5\pi - 3.5x$

$j = \pi - 2i = 7x$

Also because of the isosceles triangle, $x = i$, so we can now derive the value of $x$:

$x = 0.5\pi - 3.5x$

$4.5x = 0.5\pi$

$9x = \pi$

Now we can go back and substitute $\frac{\pi}{9}$ for $x$ and work out all the angles exactly.

We can also see a pattern in the angles. The angles of the tops of the triangles go:

$x,3x,5x,7x..$

while the angles of the sides go

$0.5\pi-0.5x$

$0.5\pi-1.5x$

$0.5\pi-2.5x$

$0.5\pi-3.5x$

$..$

So we can work out the angles of specific triangles with closed form formula, instead of having to calculate them all.

this code runs successfully but at the time of sumbit it gives me NZEC error . can you help me to rid off from this

$
0
0

cook your code here

x, y = int(input()), int(input()) if(x % 5==0): print(y) y=y-x- 0.50 print("%.2f" %(y) ) else: print(y)

EARTSEQ - EDITORIAL

$
0
0

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2

Setter:Evgeniy Artemov
Tester:Xiuhan Wang
Editorialist:Taranpreet Singh

DIFFICULTY:

Easy-Medium

PREREQUISITES:

Sieve of Eratosthenes, Number-Theory and Constructive Algorithms.

PROBLEM:

Given an integer $N \geq 3$, find $N$ distinct numbers such that every pair of consecutive numbers have a common factor $ > 1$ and all possible consecutive three elements have no common factor $ > 1$. Also, all numbers found should be between $1$ and $10^9$. First and Last elements are also considered adjacent here.

SUPER QUICK EXPLANATION

  • A simple way to generate $N$ such distinct numbers is to take a prime and multiply two consecutive elements by this number. This way, the condition of co-primes is handled, but the numbers generated go beyond $10^9$.
  • A better way would be to reuse smaller primes while ensuring all the generated numbers are distinct.

EXPLANATION

This is a constructive problem, and hence, have multiple solutions. Feel free to share your solution in comments.

Note: If we represent a number as the product of prime numbers, Prime factorization of a common factor of the pair of numbers is the common part of prime factorization. If we consider prime values or product of few primes, they have relatively lesser factors as compared to composite numbers. So, for most of the problems involving prime factors/factorization/divisibility, prime numbers bear special importance.

Let us try similar problems first.

Try solving the same problem assuming there's no upper bound on maximum values. Now, we can just multiply a distinct prime number to every pair of consecutive numbers. This way, every two consecutive numbers are not co-prime while every three consecutive numbers are coprime.

The above solution is sufficient to solve the first subtask, but in the second subtask, the values exceed $10^9$, so we need something better.

Try solving the same problem, assuming we are allowed repeated values. Here, we can choose prime numbers and multiplying each position by exactly two primes such that every two consecutive positions share prime factor while every three consecutive numbers do not share any prime factor, taking special care to choose a different prime number when reaching the end of the array.

Now, let us solve the original problem.

Think up and try to mix the above solutions so as to reduce the magnitude of generated numbers while keeping each number distinct.

The construction used in my solution is to reserve the first few primes and then multiply the first two positions by a non-reserved prime, next two positions by another prime and so on. Now, We can multiply Last and first position by a reserved prime, second and third position by different reserved prime, and so on. This way, we are guaranteed to have every pair of consecutive positions divisible by that particular prime number, and every three consecutive positions are coprime since no prime is multiplied to three consecutive positions.

Implementation

For this problem, we can preprocess and calculate a list of primes beforehand using the sieve of Eratosthenes and then for every test case, use primes from the list instead of recomputing.

Interesting Fact

This problem can also be approached as a challenge problem where we need to minimize the maximum value generated in sequence. Can you minimize? Say for $N = 50000$

Time Complexity

Time complexity is $O(MX*log(log(MX)) + \sum N)$ per test case where $MX$ is the upper limit till primes are found. Finding primes up to $10^6$ suffices for this problem.

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution
Editorialist's solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :)

EARTSEQ QUESTION


Invitation to CodeChef January Long Challenge 2019 sponsored By ShareChat

$
0
0

Happy New Year to the CodeChef community!

Celebrate the new year with CodeChef’s January Long Challenge 2019 sponsored by ShareChat. This programming contest lets you tackle 8 problems over 10 days and it’s open to programmers in every country and at every skill level. The contest problem statements will also be available in English, Hindi, Bengali, Russian, Mandarin and Vietnamese.

Participants will also have the opportunity to apply for jobs at ShareChat - India’s fastest growing social network. Visit the contest link for more details.

I hope you will join your fellow programmers and enjoy the contest problems. Joining me on the problem setting panel are:

I hope you will enjoy solving them. Please give your feedback on the problem set in the comments below, after the contest.

Contest Details:

Time: 4th January 2019 (1500 hrs) to 14th January 2019 (1500 hrs). (Indian Standard Time — +5:30 GMT) — Check your [timezone](https://www.timeanddate.com/worldclock/fixedtime.html?msg=CodeChef+January+Challenge+2019&iso=20190104T15&p1=44.

Contest link:https://www.codechef.com/JAN19

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

Prizes:

Top 10 performers in Global and Indian category will get CodeChef laddus, with which the winners can claim cool CodeChef goodies. First to solve each problem except challenge - 100 laddus. Know more here: https://www.codechef.com/laddu. (For those who have not yet got their previous winning, please send an email to winners@codechef.com)

Good Luck!
Hope to see you participating!!
Happy Programming !!

MGAME - EDITORIAL

$
0
0

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2

Setter:Smit mandavia
Tester:Xiuhan Wang
Editorialist:Taranpreet Singh

DIFFICULTY:

Easy

PREREQUISITES:

Modulo operator and Basic Combinatorics.

PROBLEM:

Given two integers $N$ and $P$, suppose the maximum value of $(((N \bmod i) \bmod j) \bmod k ) \bmod N$ be $M$ where $i, j, k \in [1, P]$, Find the number of ways to select $i, j, k \in [1, P]$ such that $(((N \bmod i) \bmod j) \bmod k ) \bmod N$ equals $M$.

SUPER QUICK EXPLANATION

  • The maximum value of $N \bmod x$ where $x \in [1,N]$, if $N$ is odd, is $(N-1)/2$ when $x = (N+1)/2$, and if $N$ is even, is $N/2-1$ when $x = N/2+1$.
  • We can achieve $(((N \bmod i) \bmod j) \bmod k ) \bmod N = M$ in three ways. Let $x = \lceil (N+1)/2 \rceil$
  • $i = x$ and $j,k > M$.
  • $i > N$, $j = x$ and $k > M$.
  • $i, j > N$ and $k = x$. Each of this case can be easily computed.

EXPLANATION

First of all, Let is find this value $M$. It has to be less than $min(i,j,k,N)$ which implies, $M < N$. Hence, if we want $M > 0$, we need $(((N \bmod i) \bmod j) \bmod k) < N$. So, We know for sure, that to maximize $M$, $min(i, j, k) \leq N$. Hence, we need maximum $(((N \bmod i) \bmod j) \bmod k) < N $ and now we can ignore the last $\bmod N$.

So, The maximum $N \bmod x$ can attain is $\lfloor (N-1)/2 \rfloor$. This happens when $x = \lceil (N+1)/2 \rceil$. It can be easily verified either by checking by hand, or writing a simple program ;)

Now, try finding out number of ways $(((N \bmod i) \bmod j) \bmod k)$ equals $M$. It can be approached in Simple case base analysis.

We can try all possible triplets of $(i,j,k)$ and generalize them into three cases.

  • When $i = \lceil (N+1)/2 \rceil$ and $j,k > M$
  • When $i > N$, $j = \lceil (N+1)/2 \rceil$ and $k > M$
  • When $i,j > N$ and $k = \lceil (N+1)/2 \rceil$

In all three cases, we can simply count the number of triplets $(i, j, k)$ satisfying any condition and print the answer.

Corner Case

When $N \leq 2$, $M = \lfloor (N-1)/2 \rfloor = 0$. This is because we cannot achieve $(((N \bmod i) \bmod j) \bmod k ) \bmod N > 0$. So, all triplets $(i, j, k)$ are valid.

Alternate solution - read at your own risk, you have been warned :D

For those curious enough not to be satisfied with such solutions, there also exists a pattern based solution too, using basic math. Just use brute solution to find the first terms of series and solve using the pattern formed. Number 6 is important. Enjoy :D

Time Complexity

Time complexity is $O(1)$ per test case.

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution
Editorialist's solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :)

Implementation of Dijkstra's Algorithm using set data structure in C++

$
0
0

I was trying to implement Dijkstra using set data structure in C++. I was coding in C++14 and there seems to be something out of order in the code for it is not giving me the right answer in Codechef IDE and on DevCpp it is not even compiling!

I believe the code is logically sound and there are only semantic errors in it.

Implementing Dijkstra using set in C++

RECTSQ, am I unable to understand?

$
0
0

https://www.codechef.com/problems/RECTSQ

My Code:

#include <stdio.h>

int ans;
int finder (int a, int b)
{
    if(b > a)
        {
            a += b;
            b = a-b;
            a = a-b;
        }

    int k = a/b;
    ans += k;
    if(a-(k*b))
        finder((a-(k*b)),b);
    else
        return 0;
}   
int main()
{
    int t;
    scanf(" %d",&t);
    while(t--)
        {
            int a, b;
            scanf(" %d%d",&a,&b);
            ans = 0;
            finder(a,b);
            printf("%d\n",ans);
        }
}

I know it is giving output as 3 even for the sample testcases given in the question, while the desired ones are 6 and 6. But I want to ask that if we have to return the minimum number of square plots then why is this incorrect? Take the first case 10, 15 for example, Square 1: 10x10 (5x10 remains from original 10x15) Square 2: 5x5 (5x5 remains from original 5x10) Square 3: 5x5 (Return to main)

So Minimum is 3 squares, why is 6 the answer? I think maybe I understood the question wrong, please help.

Thank You

GMEDIAN - Editorial (Unofficial)

$
0
0

PROBLEM LINK:
Div1
Div2

Setter:Teja Vardhan Reddy
Editorialist: Utkarsh Pandey

DIFFICULTY:
EASY

PRE-REQUISITES:
Observation, Binomial Coefficients.

PROBLEM:
Given a sequence A1,A2,…,AN. Find the number of subsequences in which the median of the subsequence is present in that subsequence, modulo 1000000007.

Explanation
Since we have to sort each subsequence to find its median, we will sort our original sequence (i.e. A1,A2,…,AN) at first itself. The ordering won't change.
For example, the good (desired) subsequences in the sequence [9,5,7,6,8,1] are same as that in the sequence [1,5,6,7,8,9].

The subsequences having odd length will definitely qualify to be one of our good subsequence (as in the subsequences with odd length, the element at the middle position is the median of the subsequence itself).

The subsequences with even length will qualify as good subsequence if and only if the middle two elements are same. It is so because the array is already sorted. View the content below in case you didn't understand this statement.

View Content

So our answer to this problem is : (Number of subsequences having odd length) + (Number of good subsequences having even length with both the middle elements equal)

First Subtask:
It is clearly written in this subtask: A is a permutation of integers 1 through N. Also, the number of elements in the sequence A is N which means each element from 1 to N is present once and only once. This tells us that there is no repetition of any number. So, no subsequence having even length will be counted.

So, answer to this subtask = Number of subsequences having odd length
= Number of ways of selecting 1 out of n elements + Number of ways of selecting 3 out of n elements + Number of ways of selecting 5 out of n elements + ............. + Number of ways of selecting n or (n-1) out of n elements

$=nC1 + nC3 + nC5 + ..... + nCn$ (if 'n' is odd) or $nC1 + nC3 + nC5 + ..... + nC(n-1)$ (if 'n' is even)
where nCx denotes the number of ways of choosing x elements out of n elements

= 2^(n-1) See the proof below if you didn't understand this completely Proof:

View Content

Second and Third Subtask:
The tricky part of this question is when the elements in the sequence starts repeating. In this case, we have to find the number of subsequences having even length. To find the subsequences of even length to be a good subsequence, we traverse through each element which is repeated at least once. For this element to be our median element in one of the subsequences of even length, we must have at least k elements at its index's left and we must have at least k elements at the other element index's right (Note that our array was sorted), where k is a non-negative integer.
An example is provided in the section below in case you didn't understand the lines written above:

View Content

Now, Calculating nCx in each iteration, we may have difficulties passing the time limit provided in the problem. To reduce the time complexity to pass the given time limit, we have to observe the given fact:

Let the repeating elements be found at index i and j Suppose, there are m elements at the left of the index i and n elements at the right of index j.

So, number of good subsequences: 1 (good subsequence of length 2) + $mC1 * nC1$ (good subsequences of length 4) + $mC2 * nC2$ (good subsequences of length 6) + ........... + $mCmin(m,n) * nC(min(m,n))$.

By Vandermonde's identity we can sum up this value as (m+n)C(min(m,n)), details of which can be found here :Vandermonde's Identity.

Bonus: Calculating queries of the type nCr % 1000000007 can be solved by precalculating $nCr % 1000000007$ upto n = whatever you need :p . Details of this can be found here: nCr % p in O(1)

Time Complexity = O($N^2$) (Enough to pass all the subtasks)

Editorialist's Solution:https://www.codechef.com/viewsolution/21611480

GetCode Codechef/Codeforces/SPOJ plugin for Sublime Text 3

$
0
0

GetCode

This is an ST3 plugin which:

  1. Take the URL of a problem such as https://www.codechef.com/problems/INVLIS.
  2. Parse the URL and get the problem code(In this case it is INVLIS).
  3. Create a new .cpp or .py file with a pre-determined template(cpp.snippets which is customized via settings).

Keyboard shortcuts

For all Operating Systems, ctrl+alt+x opens a new dialogue box which takes the problem url as user input

How to install

  1. Install Package Control from here
  2. In Sublime, Open Package Control

Open Package Control from the Preferences Menu

  1. Select Package Control: Install Packages

enter image description here

  1. Now you should be able to search for and install the GetCode Package.

How to use it

After installing, it is necessary to configure the settings(setting the default directory and snippets).

After configuring the settings, ctrl+alt+x opens a new dialogue box which takes the problem url as user input

Supported websites(for now)

  1. Codechef
  2. Codeforces
  3. SPOJ
  4. Virtual Judge

Invitation to RATED Contest(Div1+Div2) Enigma on Codechef, 10 January 2019

$
0
0

Hello, CodeChef community,

Tired of searching for the perfect teammates in every competition? Want to prove your worth as a solo coder? Looking for the perfect platform to display your skills?

This solo coding competition is designed for the masterminds who think they perform best alone.

Interested? Wanna find out more about it? No Problem! Plinth in association with Aavas Financiers Limited has a rated contest on CodeChef waiting just for you!

The contest shall be a great opportunity for students to test their programming aptitude. This national level programming contest shall assess the intelligence of participants through various rounds. It is an Online Qualifier Round for the Onsite Round to be held during Plinth'19.

There will be 2 rounds to decide the winner:

First Round: Online Qualifier for onsite will be held on 10th January 2019 on Codechef which is a rated round(Div1+Div2).

Second Round: Onsite round will be held at The LNM Institute of Information Technology, Jaipur on 20th January. More details will be announced later.

The Contest details of Enigma'19 are as follows:
- Contest duration will be 3 hours.
- Solo Coding Event
- Start time: 10th January 2019, 21:00 hrs IST
- End time: 11th January 2019, 00:00 hrs IST

Contest Link: Click Here

Problem Setters: panikxodiacaditya10_tds115

alt text

Good Luck and have Fun!


Getting java NZEC error on codechef compiler

$
0
0

Guys i am trying to solve the DAG Delete problem of December contest. My code runs perfectly fine on my computer and i have tested it for multiple cases. I have also made sure that everything is properly initialized and checked for corner cases too. Earlier i was using too much memory and even that is not the case now. Please tell me what are the not so common reasons where you people got Run Time Error or how should i proceed with debugging my code.

Best Regards

Why doesn't Codechef put editorials of all problems !

$
0
0

Is there nobody answerable to providing editorials of contest problems. Let go other open and unrated contests, we are talking about monthly rated contests. Several times the editorials don't appear not even the unofficial ones, particularly to tough problems. Besides, not to ignore the fact that for even the other problems it takes a minimum of 3 days to put the editorials.

https://www.codechef.com/LTIME67A/problems/NOSS

Come on Codechef, this hasn't happened the first time.

MySql database creation

$
0
0

Need help how to create database in mysql via chef .Iam able to install mysql and now i need to create database i don't know the syntax how to create database.Thanks .

DIFNEIGH - EDITORIAL

$
0
0

PROBLEM LINK:

Practice
Contest: Division 1
Contest: Division 2

Setter:Evgeniy Artemov
Tester:Xiuhan Wang
Editorialist:Taranpreet Singh

DIFFICULTY:

Easy-Medium

PREREQUISITES:

Pigeonhole principle, Constructive algorithms and Case-based Analysis.

PROBLEM:

Given two integers $N$ and $M$, find out any matrix with $N$ rows and $M$ columns using as less distinct numbers as possible, such that for all cell, all values of neighbors of that cell are pairwise distinct.

SUPER QUICK EXPLANATION

  • In all cases, it can be seen that if $K$ is the maximum number of neighbors for any cell, It is not possible to have any valid table using less than $K$ distinct numbers due to Pigeonhole principle.
  • Turns out, it is always possible to make a valid table using $K$ numbers. One possible construction is noticing that ith position in the row should have values different than (i-2)th position and (i+2)th position in the same row. Same goes for columns. Constructions exist based on this condition only.

EXPLANATION

Considering a $N*M$ table, we can see that if the maximum number of neighbors any cell has in a table is $K$, there cannot exist any valid table using less than $K$ distinct values. The reason is, that if we take $K$ values out of distinct $ < K$ values, It is guaranteed to have at least one value occurring more than once, which means that the values of neighbors of that particular cell are not pairwise distinct. Hence, the table is invalid. Refer Pigeonhole principle for proof.

Thus, we need to find a way to fill the table using $K$ values.

General case

In general case where we have $K = 4$, occurs when both $N, M \geq 3$.

Here, in every row or column, we need the first element to differ from the third element in the row, the second element should differ from the fourth element, the third element should differ from the fifth element and so on. If we choose the fifth element to be the same as the first element, it shall make no difference.

It is recommended to try a few ways to fill a $4*4$ table and then trying to extend it either way.

Here, it is possible to have different constructions than the one mentioned here, so feel free to share yours.

One possible way to fill a $4*4$ table is

1 1 2 2 3 4 4 3 2 2 1 1 4 3 3 4

Now, it can be easily seen, that we can just keep appending rows and columns without causing any conflict for any cell, thus efficiently generating our table.

View Content

Special cases

Assuming $N \leq M$. Values $N$ and $M$ can be swapped if otherwise.

  • If $N$ equals one. Here, if $M \leq 2$ each cell has at most one neighbor, and thus, we can just assign 1 to both cells. If $M > 2$, we need the first element to differ from third, second from fourth and so on. So, we can just assign the first four values as 1 1 2 2 and from the fifth element, ith value is assigned same value as (i-4)th element.

  • If $N$ equals two. Here too, if $M == 2$, valid table exist with $K = 2$. Otherwise, we need at least three distinct values. A simple construction being ith element in both rows being assigned as (i-3)th element, first three elements being 1 2 3.

This covers all cases where $K < 4$. All other case have $N, M \geq 3$ which implies $K == 4$ as seen above.

Time Complexity

Time complexity is $O(N*M)$ per test case.

AUTHOR'S AND TESTER'S SOLUTIONS:

Setter's solution
Tester's solution
Editorialist's solution

Feel free to Share your approach, If it differs. Suggestions are always welcomed. :)

Help for SEACO

$
0
0

hi , i am not able to find out whats wrong in my solution for the problem "Sereja and Commands"(https://www.codechef.com/problems/SEACO ) . I am implementing a fenwick tree approach , in which i am applying all the commands of type "1" in my array a all commands of type "2"are pushed in a vector, then i am traversing the vector from back and implementing all the commands of type "2" on another BIT one by one .The second BIT is used for storing the count of all the commands with particular index , then finally implementing all the commands of type "1" on my array a . map 'c' and 'd'are used for the storing the type and range of the a particular command respectively. I checked in the editorial discusions that my approach is correct but not able to find the error in my code. my submission link (https://www.codechef.com/viewsolution/22518842 )

Viewing all 39796 articles
Browse latest View live


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