Изменения рейтингов за последние раунды временно удалены. Скоро они будут возвращены. ×

Блог пользователя Harolinch

Автор Harolinch, история, 8 лет назад, По-английски

i'm try to solve this graph problem (double profiles) and it requires to use hashes in order to solve the problem.

first of all, i didn't solve the problem and and if anyone could give me help, i appreciate that.

secondly, when should i know that i need to use hashes to solve a graph problem (what is the properties of the graph problems that need hashes)

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
8 лет назад, скрыть # |
Rev. 27  
Проголосовать: нравится +7 Проголосовать: не нравится

The hash approach seems to be related to the more abstract problem of equality checking of a pair of subsets Si and Sj of V = {1, 2, ..., n}.

Hashing should find the answer to the equality checking Si = Sj indirectly by computing the hash key h(Si) for each subset, and then checking if h(Si) = h(Sj), provided that the no collision takes place, i.e. no pair (i, j) exists, where i ≠ j, such that Si ≠ Sj and h(Si) = h(Sj). In other words, the hash key function should be a one-to-one mapping that enumerates the existing distinct subsets of V by assigning them distinct identification numbers which can be checked for equality more efficiently.

The solution of the original problem should then be equal to the cardinality of the set of pairs P = {(i, j)|1 ≤ i ≤ n - 1, i + 1 ≤ j ≤ n, h(Si) = h(Sj)}.

In test case 1, for example,

  1. When checking the pair (1,2): S1 = S2 = {3}. Therefore, 1 and 2 are doubles.

  2. When checking the pair (1,3): S1 = S3 = {2}. Therefore, 1 and 3 are doubles.

  3. When checking the pair (2,3): S2 = S3 = {1}. Therefore, 2 and 3 are doubles.

In all cases, if i and j are friends, their friendship is not included in the neighborhood when checking if i and j are doubles.