ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1827. Indigenous Wars

what is test 22?
Posted by tracyzhu 23 Mar 2011 21:11
tle at test 22...
Re: what is test 22?
Just some big test, probably without any 1's in the answer. To speed up your code, don't use stl structures - write your own hash.
Re: what is test 22?
Posted by tracyzhu 24 Mar 2011 16:10
i have written my own hash to store m internal conflict and then check all n days.but also got tle.
It is driving me mad!
Do you have some better solutions?
thx for help me.

Edited by author 24.03.2011 16:11

Edited by author 24.03.2011 16:15
Re: what is test 22?
No, my solution is pretty straightforward - take every day and for all i from 1 to 50 check whether triple (a[n], a[i+n], i) occurs in the sequence that was read from the input. Overall complexity is O(50*n) assuming complexity of your hash is O(1)

Edited by author 24.03.2011 16:22
Re: what is test 22?
Posted by tracyzhu 24 Mar 2011 19:29
I want know how to hash triple(ai,bi,di)..i use a list hash[len][ai] and scan it.I think it is the reason i got tle...
Re: what is test 22?
Posted by tracyzhu 25 Mar 2011 10:45
still tle or wa...
Re: what is test 22?
Posted by svr 26 Mar 2011 13:06
AC with STL
Hashing is somthing terrible.
1)form all possible segments ;2) sort it 3) find all belongings for each given conflict;
3) apply segment union - O(n) algo(very important! classical!)