Program | URL.PAS, URL.C, URL.CPP |
Given the set of URLs (Uniform Resource Locator) the task is to count the number
of the correct URLs corresponding to the following grammatical rules.
Explanation of some notational constructs:
xxx yyy - xxx should be followed by yyy xxx | yyy - xxx or yyy should appear "xxx" - xxx should appear explicitely xxx - rule xxx should be applied [ xxx ] - xxx is optional *[ xxx ] - xxx is repeated zero or more times httpurl = "http://" hostname [ "/" hpath [ "?" search ]] hpath = hsegment *[ "/" hsegment ] hsegment = *[ uchar | ";" | ":" | "@" | "&" | "=" ] search = *[ uchar | ";" | ":" | "@" | "&" | "=" ] hostname = *[ domainlabel "." ] domainlabel domainlabel = alpha | alpha *[ alphadigit | "-" ] alphadigit uchar = alpha | digit | safe | extra alphadigit = alpha | digit alpha = "a".."Z" | "A".."Z" digit = "0".."9" safe = "$" | "-" | "_" | "." | "+" extra = "!" | "*" | "'" | "(" | ")" | ","
Input:
4
http://www.rtk.si
http://www.nexor.com/public/rfc/rfcs/rfc1738.txt
http://av.yahoo.com/bin/query_uk?p=Tralala&z=2&hc=0&hs=0
http://vlado.mat.uni-lj.si/sreda/sreda.htm
3
http://www.3com.com
http://www-ai.ijs.si\slais\slais.html
http://www.ijs.si/cgi-bin/email?lang=[en]
Output:
4
0