I have not been able to solve this problem.Can any tell me how to solve it.The best i can think is of djikstra,but that will obviously give me time limit exceeded.Can anyone tell me the solution.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | Dominater069 | 154 |
8 | awoo | 154 |
10 | luogu_official | 151 |
I have not been able to solve this problem.Can any tell me how to solve it.The best i can think is of djikstra,but that will obviously give me time limit exceeded.Can anyone tell me the solution.
Name |
---|
You can use binary search. Then for fixed answer X you may check it in O(N+M) — bfs over modified graph with states [vertice of original graph][number of edges with weight >X in path].
I didn't get the modified graph part.Can you please ellaborate.
We are interested in weight of second heaviest edge on the path. If we'll use binary search — then question is modified to can we find a way from start to finish with second heaviest edge of weight no more than X, and this one is equal to can we find a way from start to finish wish <=1 edges of weight more than X in it.
And now it is clear that you are interested only in your current vertex and number of used "heavy" edges (because you can't use "heavy" edge if you used 1 before — then you'll have 2 "heavy" edges in your path).
How to solve problem L :) http://mirror.codeforces.com/gym/100460/problem/L Thanks in advance :)
Looks like we can find for each man the interval of possible relation (from any event we know that for any man realtion <=x) and then check for each event that exists man who took part in it and can have realtion equal to event's relation.