You are not logged in. Please login at www.codechef.com to post your questions!

×

Need help with INTXOR December Challenge

Hello..Can someone please help me with my IntXor logic which was asked in December18 Long Challenge. Here is how I approached to the problem -
I found out that we can divide our arrays in lengths of 4,5 and 7 i.e when (N%4=0), (N%4=1),(N%4=2)(2 parts of length 5 each) and (N%4=3) respectively. Now I will ask my queries in the cyclic manner.
For eg - if part length = 4,then my queries will be
1 2 3 = a
2 3 4 = b
3 4 1 = c
4 1 2 = d
Here a,b,c,d are the answers of the queries. Now we can easily find the values of these 4 indices . For eg- A[1] = a^c^d, A[2] = a^b^d and so on..

if length = 7, queries will be
1 2 3 = a
2 3 4 = b
3 4 5 = c
4 5 6 = d
5 6 7 = e
6 7 1 = f
7 1 2 = g
Here, a[1] = a^c^d^f^g , a[2] = b^d^e^g^a, a[3] = c^e^f^a^b and so on in the cyclic manner..

if length = 5, queries will be
1 2 3 = a
2 3 4 = b
3 4 5 = c
4 5 1 = d
5 1 2 = e

Solving this part is somewhat tricky. But we can solve by first finding a single element and then using it to find the other elements. For eg - to find a[3] we can find it by using - a^c.
This gives me the answer of 1^2^4^5. Therefore, my a[3] = a^b^c^d^e^a^c which is technically, b^d^e.
Now we can xor this answer we calculated for a[3] with c to get 4^5. Now, using this we can find a[1] because of the reversal property of xor and similarly we can find all the other elements.
However, I don't know why all my TestCases weren't accepted on submission. Kindly look into my code and please help if you find any fault in the logic or code. Thankyou :)

Here is my code

This question is marked "community wiki".

asked 20 Dec '18, 10:08

dipanshu_10297's gravatar image

3★dipanshu_10297
01
accept rate: 0%

edited 20 Dec '18, 10:09

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×15,499
×2,701
×376
×102
×36

question asked: 20 Dec '18, 10:08

question was seen: 150 times

last updated: 20 Dec '18, 10:09