hi , i am new to codechef . I have participated in march long challenge .
I want to ask about a problem that was asked in the challenge -> XORengine .
See my code once that i have tried , please tell me why its not working .
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
int* ar = new int[n];
ar[i] = (p ^ ar[i]);
int val = ar[i];
cout<<counteve<< " "<<countodd<<endl;
hey @hackinet i used t - - only but here due to editor of codechef it seems to be hyphen .
So try getting me whats wrong in the code instead of arguing with me . now i have given more space between them , try to see it carefully .
@anon86902332 My apologies. Do you get TLE or WA?
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
@hackinet i was getting WA .
The correct output(what the output should be):
hey i can get that there exist some output mismatch with my code thats why i got WA . but can you get me that what is the logical error in my code . As in my code i am check each bit of the each element and then i am keeping count of 1’s and thus at last i am determining
the even / odd . Can you tell where it is going wrong ??
ar[i] = (p ^ ar[i]); //<- Your Error.
- You take a input p and XOR it with all the elements of A[i].
- A[i] now contains different elements. NOT the original elements.
- You take input p again but this time, you won’t have the original A[i], because during previous p input you updated all the A[i].
okay thanks @hackinet . I got my mistake .