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

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

**Hi. A few days ago I have solved a Problem on UVa named Virtual Friends .

The link is here : Click Here .

This is a Union Find / Disjoint Set Find problem . I used that algorithm and Got Accepted verdict at 2.281 Sec. Although the problem says it's Time Limit is 10 Sec. May be the data set is Huge. I have seen the Best Submission ever for this problem is 0.104 Sec.

Now my Question is how to decrease my Run Time?? I want to get Accepted verdict less than 1 Sec. How to optimize my Code ??

My Code is : http://ideone.com/34YqH9

Thanks is Advance.**

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

»
9 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

You could try to use fast I/O.

»
9 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

You can hash the string instead of putting it into a map.