You can't actually have perfect knowledge about the length of any sunken ship under those rules. You can assign some probability, but there's no way to get the length of a particular ship. Consider the one-dimensional version:
0123456789
.XXXXXYY..
Where "X" and "Y" represent different ships. If you start firing at position 4, and keep going right, you'll sink a ship after 4 hits. You know the ship you just sunk is no more than 4 spaces long, but it could be anything from 1-4 spaces in practice.
The most likely thing is that you hit a single ship, but you can verify that by back-tracking from the first hit. In this case, you'll get hits all the way back to position 1, and then another ship will be reported as "sunk". So you know that ship X + ship Y are a total of 7 spaces long. There are only a few combinations that can add up to 7, so there's some information there. Unfortunately, there are a number of possible two-ship combos that add up to 7.
It's much worse on the 2D board:
0123456789
A..........
B..........
C..A.......
D..A.......
E..ABCDEE..
F...BCD....
G...BCD....
H....CD....
I.....D....
J..........
If you shoot from E0 to E9, you'll score 6 hits, and one sunk. Without checking each spot from D2 to D7, you can't be sure whether any of those hits was on a perpendicular ship sticking down into row E. You'd also have to check F2 to F6, to make sure there are no ships in the other direction.