Advertisement
skimono

Untitled

Apr 4th, 2024
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. Querry Q[max_sz];
  2. ll key[MOD];
  3. int val[MOD];
  4.  
  5. struct hsh_table {
  6.     ll k;
  7.     void add(ll pos, int value) {
  8.         for (k = pos % MOD; k < MOD; k++) {
  9.             if (key[k] == 0) {
  10.                 key[k] = pos;
  11.                 val[k] = value;
  12.                 break;
  13.             }
  14.         }
  15.     }
  16.     int que(ll pos) {
  17.         for (k = pos % MOD; k < MOD; k++) {
  18.             if (key[k] == 0) {
  19.                 return 0;
  20.             }
  21.             if (key[k] == pos) {
  22.                 return val[k];
  23.             }
  24.         }
  25.         return 0;
  26.     }
  27. };
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement