Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

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

How to find the number of words of length N<4000, given that there are K number of forbidden sequences(K<2000). Each forbidden sequence is given and length of a forbidden sequence is less than N. Each word is made up of S number of characters (S<4000). So total number of words are S^N. Sum of length of forbidden sequences is less than 4000.

Cheers

Полный текст и комментарии »

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

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

What is the algorithm for merging two different sets ?

inline int find(int x){ return (parent[x] == x ? x : find(parent[x])); }

inline bool merge(int x, int y){ x = find(x); y = find(y); if(x == y) return false; if(r[x] > r[y]) x = y + x — (y = x); parent[x] = y; if(r[x] == r[y]) r[y]++; return true; }

Thanks in advance.

Полный текст и комментарии »

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