Ask these questions here (I will upgrade them into independent thread if approved) till you get 3 karma to ask your own questions. We dont downvote questions at all until they are serious violations or really repetitive questions.
That actually is a complicated code XD. You can mail me requests to add comments to my code, in case I fail to see it here.
My solution essentially tries to speed up the brute force task. Bucket is made of 3 things- buckxor (xor of bucket), xors (a sort of carry over. If element i is updated from x to y, then whats the effect of it over xor of future buckets? The âoriginalâ or âprefix-xorâ becomes (original^x^y). [The x removes contribution of x in original, and then we xor y]).
The map is like: mp[i]=number of sub arrays with xor i. Rest of code is how we can perform queries using these.
Yeah okay , from which problems should i start with to improve my programming skills so as to solve problems like these say easy-medium , I can solve pretty much first 3 to 4 in long challenges after that it just becomes tough
TY in advanced
Its not a medium. I believe this problem also went to âEasyâ section. You can start from there. Once you get confident, proceed to Medium section
Thanks so much! I fixed my code to work now.
In the future, what are some ways to find out what the testcases are, when I get WA?
Also, how does one get Karma?
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 ran into the same problem, and I posed the question in my answer to this thread. My hypothesis is that the test cases were formatted incorrectly, meaning our use of BufferedReaders and going line by line caused an NZEC. I hope we can figure this out.
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?
-
What is the error made here?
-
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
SIGBRT error can be easily googled. It means you are allocating too much memory/ have crossed the memory limit. You cannot declare arrays of size {10}^{9}.
Suggest resources for learning C++ for Competitive coding. I know C and Java.
Please use search feature of the forum or google.
Wrong Editorial link
Hey @vijju123, @admin,
The editorial link for the problem BWCELL, https://www.codechef.com/LTIME30/problems/BWCELL and https://www.codechef.com/problems/BWCELL is wrong. It should be https://discuss.codechef.com/questions/76899/bwcell-editorial .
Reported. Thank you.
You are welcome.
@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.
@bitthal04 Do the following
-
Go to your profile, click edit
-
Go to professional and then add your school name in âWhere do you studyâ
If you will not find your school name there, then click on âOtherâ then another option come âEnter new institution name:â here you will add your school name. Then admin will check and add your school.
Hope this answer is helpful.
@codex0196 I have already done that but neither I am alloted junior ranking not I am able to see myself in Schools Ranklist thatâs why I m curious if I would get laddus or not
You are not allotted junior ranking because your school is not in the database. Once admin will add your school(if you did the following steps I have mentioned above), your junior ranking will be shown and laddus will be awarded.
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
Although it is not a big issue, but still posting.
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, https://daringfireball.net/projects/markdown/syntax can be used for markdown help.
Please mail me or codechef the relevant screenshot and additional details.