Xor It - CodeChef
Xor It - CodeChef
Xor it CodeChef
Hello m ithunam k777! Account or Log Out
Login or Signup with
Connec
PRACTICE
Home Compete March 2012 Challenge Xor it
COMPETE
DISCUSS
COMMUNITY
HELP
ABOUT
Xor it
Problem code: XOR Send 3 people ecommend ALL SUBMISSIONS MY SUBMISSIONS SUBMIT
Chef has given you a sequence A[1], A[2], ..., A[N] composed of N nonnegative integer numbers. Then, for each pair (i; j) such that 1 <= i < j <= N, we have written a number that equals to A[i] xor A[j] (xor is exclusive or, "xor" in Pascal, "^" in C++). Thus, we have obtained N*(N-1)/2 numbers. Your task is to find K minimal numbers among them.
SUCCESSFUL PROBLEM:
SUBMISSIONS
FOR
THIS
Oops, we couldn't seem to load the successfull submission Try again soon.
Input
The first line of the input contains two space separated integers N and K. Each of the next N lines contains one integer, ith line contains number A[i].
Output
In the only line of output print space separated sequence of K numbers, the answer to the problem. Numbers should be in non-decreasing order.
Constraints
2 N 100000 1 K min{250000, N*(N-1)/2 0 A[i] < 231
Example
Input: 45 1134 Output: 02255
Explanation
In the sample input we have 4 numbers: 1, 1, 3, 4. Therefore, there are (4*3)/2 = 6 pairwise XOR's. These XOR's are: 1 xor 1 = 0 (A[1] xor A[2]) 1 xor 3 = 2 (A[1] xor A[3]) 1 xor 4 = 5 (A[1] xor A[4]) 1 xor 3 = 2 (A[2] xor A[3]) 1 xor 4 = 5 (A[2] xor A[4]) 3 xor 4 = 7 (A[3] xor A[4]) If we sort these numbers we will obtain: 0, 2, 2, 5, 5, 7. The first 5 minimal numbers are: 0, 2, 2, 5, 5. Date: Time limit: Source limit: 2012-02-04 2s 50000
TCL PERL6 CLOJ GO PYTH 3.1.2 F# C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE Languages: PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK TEXT JS
www.codechef.com/MARCH12/problems/XOR
1/4
3/6/12
SUBMIT
Xor it CodeChef
Comments
tijofor ou @ 1 Ma 2012 04:59 PM Please clarify... The input section reads, "The first line of the input contains two space separated integers N and K. Each of the next N lines contains one integer, ith line contains number A[i]." But the example has only a single line containing N integers, following the first line. Which one is correct??
serge _adm @ 1 Ma 2012 05:09 PM @tijoforyou "The first line of the input contains two space separated integers N and K. Each of the next N lines contains one integer, ith line contains number A[i]." is correct.
rbkr @ 1 Ma 2012 08:34 PM I still can not understand it. The example shows only 1 line even though N=4. So does it mean it contains 3 more lines of input which is missing in the example?
serge _adm @ 1 Ma 2012 09:33 PM The example should be read as: 4 5[newline] 1[newline] 1[newline] 3[newline] 4[newline]
ni a nigmatul @ 3 Ma 2012 02:12 AM What kind of computer are our solutions being tested on?
ankitkalia100 @ 4 Ma 2012 01:30 AM 1xor3=2, 1xor4=5 how is it possible...in one case there is subtraction and in other it is addition???
ashish.pant @ 5 Ma 2012 04:35 AM Not a good problem. Something different should have been given for the second hardest problem (excluding the challenge).
www.codechef.com/MARCH12/problems/XOR
2/4
3/6/12
Xor it CodeChef
adit a_1itj @ 5 Ma 2012 12:30 PM @ADMIN please explain the output? if there should be n or sth else after the ans.? minimal no. has some other meaning(my interpretation:first 5 no.s of sorted 6)? xor is bitwise xor? 1^1|0^0=0 else 1.
serge _adm @ 5 Ma 2012 01:52 PM It is not specified in the statement that the input is always in the sorted order, so you can't assume it. XOR is standart operation on numbers.
saurabhskj @ 5 Ma 2012 02:05 PM @admin: can u tell me why am i getting the runtime error(NZEC)?.. i have checked out my program for any kind of Exceptions.
serge _adm @ 5 Ma 2012 03:13 PM @saurabhskj You can't ask for help during the competition. I guess, only clarifying the statement is OK.
Save
CodeChef is a non-commercial competitive programming community About CodeChef About Directi CEO's Corner C-Programming Programming Languages Contact Us The time now is: 06:20:54 PM
2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ by Sphere Research Labs In order to report copyright violations of any kind, send in an email to [email protected]
CodeChef was created as a platform to help programmers make it big in the world of computer programming. At CodeChef we work hard to revive the geek in you programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. providing a platform for programming competitions, CodeChef also has various tutorials and forum discussions to help those who are new to the world of computer pro
Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our judge accepts solutions in over 35+ programming languag programming was never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple competitions that take place through-out the month on CodeChef.
Here is where you can show off your computer programming skills. Take part in our 10 day long monthly programming contests and the shorter format Cook-off contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodie
www.codechef.com/MARCH12/problems/XOR
3/4
3/6/12
Xor it CodeChef
Discuss
Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helpin programmers and share their ideas.
CodeChef Community
As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competit the only feature on CodeChef. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your CodeChef and be a guest author on our blog. Domain Name Registration, Web hosting, and Website Design provided by BigRock.com
www.codechef.com/MARCH12/problems/XOR
4/4