About gcc and std::hash

Правка en2, от komendart, 2016-05-18 19:28:39

Hi everyone!

I don't know, maybe this topis was discussed on Codeforces but google didn't help me.

It seems that standart hash function in gcc works badly (for Visual C++ all is good).

For 0 ≤ x ≤ 232 - 1

std::hash<int>()(x) == x 
std::hash<long long>()(x) == x

For any other number

std::hash<long long>()(x + (1LL << 32)) == x

For example code in spoiler works more than 10s on Codeforces because hashes of all numbers are equal to zero.

Код

What can we do without writing our own hash function?

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский komendart 2016-05-18 19:54:02 32 Tiny change: ' '
ru3 Русский komendart 2016-05-18 19:53:24 32 Мелкая правка: '< 32)) == x\n~~~~~\n\' -> '< 32)) == std::hash<long long>()(x)\n~~~~~\n\'
en4 Английский komendart 2016-05-18 19:43:41 15 Tiny change: 're than 10s on Codef' -
en3 Английский komendart 2016-05-18 19:31:42 15 Tiny change: ' summary="Код">\n\n~~~~' -> ' summary="Code">\n\n~~~~'
en2 Английский komendart 2016-05-18 19:28:39 11 Tiny change: 't google don't help m' -> 't google didn't help m'
en1 Английский komendart 2016-05-18 19:28:09 923 Initial revision for English translation
ru2 Русский komendart 2016-05-18 19:18:56 77
ru1 Русский komendart 2016-05-18 19:17:19 885 Первая редакция (опубликовано)