OLOLO - Onotole needs your help

Onotole has a lot of pyani. Each pyani has a number, writing on it. Pyanis with equal numbers are indistinguishable. Onotole knows everything, so, he knows that each pyani appeared twice, and only one pyani is unique. He wants to get вздръжни эффект, and he needs the unique pyani. Given the list of pyanis denote which one of them appeared once (it is guaranteed that other pyanis appeared twice).


First line of input contains number of pyanis N <= 500 000. Next N lines contain a single positive integer 1 <= Pi <= 10^9.


Output one positive integer on pyani, which appeared once.



Output: 8

Onotole has found not optimal AC algorithms, so all solutions will be rejudged. He is watching you.

hide comments
rjv01: 2024-01-11 15:02:45

1. Using hash map
take inputs and store it then make condition where count(freq) of any element is 1 then print that.

2.using XOR(learn from comment section )
take inputs no need to store in arr or vector , declare ans = 0 , ans = 0 and as inputs come 0^1 = 1 then 1^8 = 9 and then finally last input 9^1 = 8.

its better u choose long long int or just long long . in my case cin cout works fine , u can use scanf("%lld",&a) and print("%lld",ans);

Good luck see. Dont give up.
(I just gave up crying in corner emoji on segment tree spoj ques and then find this ques to boost my tittle confidences).


Last edit: 2024-01-11 15:05:07
mawr_ty: 2020-06-19 19:44:46

AC in one go.Used HashSet in Java :)

abhishek_251: 2020-04-19 20:09:48

use xor only and no need to maintain an array..... got AC without using fast i/o.

subhamm99: 2019-06-17 22:07:07

got ac..just use scanf instead of cin if your logic is correct to avoid tle..

anand_undavia: 2019-06-17 21:53:16

Onotole hates Java. :P
Java: xor + buffered reader + buffered writer => TLE
C: xor + scanf + printf => AC -- (that too in 0.10 seconds -- given limit 0.134s is quite tight!)

sarthak_1998: 2019-05-20 17:40:16

Got AC only after using ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

aj_254: 2019-05-06 10:33:09

ez in python just for output stdout.write and for input use stdin.readline and main logic of program is by xor.....solvable in python ..so do not make excuses

rahul11197: 2019-03-20 13:14:34

use XOR, good one
or simple you can use map to store frequency and search for element which has frequency=1 in map

Last edit: 2019-03-20 13:26:35
itzsowvik: 2019-02-12 13:46:14


Use it and use cin, cout and get AC!

roopammishra: 2019-01-09 10:56:49

Sort then find!!:)

Added by:Efim
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64