My code gives the answer right on my linux(ubuntu) computer but it fails at system testing. I believe it's something about vectors I use in the code (ans
,tem
) but I could not find the exact reason. Any ideas? (Also it could be nice if someone tests the code. Maybe it will fail on other computers as well. Who knows?)
EDT: Problem solved
Accepted code : http://codeforces.me/contest/587/submission/14438541
Auto comment: topic has been updated by burakcetin (previous revision, new revision, compare).