PengsenMao's blog

By PengsenMao, history, 7 years ago, In English

Hi guys, i participated srm717 last night, and submitted q1, here is my idea (but failed in system test, i have no idea)

First we know there is one and only one solution, which makes the difficulty of this problem locate on constructing the graph.

So i came up with a greedy idea:

(1) we sort S[] from small to big, then we bruteforce i from 1 -> n

(2) we try to choose some nodes to be connected with node i, the nodes should satisfy that

they haven't been connected with i yet

their outdegree should be as small as possible

then i passed all the examples but got failed in system test.. i am a bit curious

btw the contest is not active therefore i can't see the test data

Thanks guys :)

  • Vote: I like it
  • +18
  • Vote: I do not like it