SRM 151

文字列が与えられ、その文字列の中に他の文字列の先頭語となるようなものがあるか判定する問題。
実装に戸惑ってしまい240点を切ってしまった。


得点:236.67/250
実装(VB.NET)


Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Text
Imports System.Math
Imports Weight=System.Int32

Public Class PrefixCode
Public Function isOne(ByVal words As []String[]()) As []String[]
Dim i As Integer,j As Integer
Dim Res As Integer=9999999
Dim OK As Boolean=True
For j=0 To Ubound(words)
For i=0 To Ubound(words)
If words(j)<>words(i) Then
If words(j).Startswith(words(i)) Then
OK=False
Res=Math.Min(Res,i)
End If
End If
Next
Next
If OK Then
Return "Yes"
Else
Return "No, "+Res.ToString()
End If
End Function
End Class