Code: Select all
3 5 2
##@**
.~*~.
.....
3 5 2
##.**
.~*~.
.....
3 5 2
##.*.
.~*~~
.....
Code: Select all
3
2
2
Any tricky cases? I keep get wa. Thanks.
Moderator: Board moderators
Code: Select all
3 5 2
##@**
.~*~.
.....
3 5 2
##.**
.~*~.
.....
3 5 2
##.*.
.~*~~
.....
Code: Select all
3
2
2
Ah yes, ... but in this case, I guess this approach would work:mf wrote:Just ignore it - time doesn't matter.
In this problem people can stay at the same place for any period of time and nothing bad will happen. So, you could make people move to their destinations by one person at a time, and in this scenario no two persons would ever be at an iceberg at the same time.
mf wrote:If you make and post some inputs, I can show the output of my accepted program for them.
Code: Select all
3 3 1
*.*
@#@
*.*
Ans: 1
1 12 1
*#*#*#*##***
Ans: 5
2 12 1
*~*~*~*~#***
..@.@@@@.@@@
Ans: 1
2 12 2
*~*~*~*##***
..@@@@@@.@@@
Ans: 4
Okay. I tried many more, got them right.mf wrote:That's all correct.
Hmm, but if I do that, for this case:mf wrote:It seems correct to me.
But you could make it simpler - set all edge capacities to infinity, except for those which connect to ~ cell.
Code: Select all
3 5 2
##.**
.~*~.
.....
Thanks mf, I got it AC.mf wrote:It seems correct to me.
But you could make it simpler - set all edge capacities to infinity, except for those which connect to ~ cell.
Code: Select all
for all vertices u,v:
add (2u,2u+1) with vcap(u)
add (2v,2v+1) with vcap(v)
add(2u+1,2v) with edgecap(u,v)
Code: Select all
add (2u,2u+1) with vcap(u)
add (2v,2v+1) with vcap(v)