Hi,
I was trying to solve this problem (https://a2oj.com/p?ID=332) Any help would be appreciated
Thanks
# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | djm03178 | 152 |
Hi,
I was trying to solve this problem (https://a2oj.com/p?ID=332) Any help would be appreciated
Thanks
Name |
---|
I thought about this problem for a while, and someone proved me that this is NP hard, cause its 'find hamiltonian path' if theres only 1 color. I might be wrong tho, but i didnt came up with any flow-like solution, except for 'shuffle-shuffle-shuffle till we good', but it has exponentional complexity
max-cost(take negative costs) max-flow solution: choose which one of cells you start with and which you end with in one of 2^X ways for each color. Now (start,end) of each color is fixed. Edges from super-source to starts with cap=1, cost=0, from ends to super-sink with cap=1, cost=0, from each vertex to adjacent vertices(cap=1,cost=0). Also, vertex capacities=1(cap=1,cost=1). If flow=X and cost=n*m-2*X, then output solution backtracking from residual edges.
Time Complexity: O(2^X*F(n*m)) where F(n*m) denotes flow complexity(depends on flow algorithm used) for a single graph.
How does it guarantee that colors are conected correctly? I mean why isnt it possible that flow from red source goes to blue sink?
And also why does this approach find hamiltonian path? Well it doesnt, right? So it has to be wrong