SPOJ TOURNEY.CPP SegTrees Example