#CJam, (削除) 116 106 99 84 77 (削除ここまで) 72 bytes
CJam, (削除) 116 106 99 84 77 (削除ここまで) 72 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z'K*S/:!0a/1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 77 (削除ここまで) 72 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z'K*S/:!0a/1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
CJam, (削除) 116 106 99 84 77 (削除ここまで) 72 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z'K*S/:!0a/1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 77 (削除ここまで) 7772 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z{Sz'K*S/1>W<:!0a/~}%1fb$W=1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 (削除ここまで) 77 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z{S/1>W<:!0a/~}%1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 77 (削除ここまで) 72 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z'K*S/:!0a/1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 (削除ここまで) 8477 bytes
l:X;93,72>{:D;Q:OXSD;OOXS/Sf+{_O+S+_2$+,D<{O\++}{\O@@);a+\}?:O;}/Oa+a+}%{z{S/1>W<:!0a/~}%1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 (削除ここまで) 84 bytes
l:X;93,72>{:D;Q:OXS/Sf+{_O+,D<{O\+}{\O);a+\}?:O;}/Oa+}%{z{S/1>W<:!0a/~}%1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)
#CJam, (削除) 116 106 99 84 (削除ここまで) 77 bytes
l:X;93,72>{:D;OOXS/{S+_2$+,D<{+}{@@);a+\}?}/a+}%{z{S/1>W<:!0a/~}%1fb$W=}0ドル=N*
Takes the single line input and prints the correct output to STDOUT.
UPDATE : Improved a lot and removed redundant loops by doing all calculations in the sorting loop itself. Also fixed a bug in river length calculation.
Explanation soon (after I golf it even further)