{"id":263,"date":"2012-11-14T15:40:00","date_gmt":"2012-11-14T07:40:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/168"},"modified":"2012-11-14T15:40:00","modified_gmt":"2012-11-14T07:40:00","slug":"poj_3080_longest_common_substring","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=263","title":{"rendered":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09"},"content":{"rendered":"<table border=\"0\" width=\"100%\" background=\"http:\/\/poj.org\/images\/table_back.jpg\" style=\"font-family:Simsun\">\n<tbody>\n<tr>\n<td>\n<div style=\"position:absolute; right:10px\">Language:<select size=\"1\"><option value=\"default\" selected=\"selected\"><br \/>\nDefault<\/option><\/select><\/div>\n<div class=\"ptt\" lang=\"en-US\" style=\"text-align:center; font-size:18pt; font-weight:bold; color:blue\">\nBlue Jeans<\/div>\n<div class=\"plm\" style=\"text-align:center; font-size:12pt\">\n<table align=\"center\">\n<tbody>\n<tr>\n<td><strong>Time Limit:<\/strong>&nbsp;1000MS<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Memory Limit:<\/strong>&nbsp;65536K<\/td>\n<\/tr>\n<tr>\n<td><strong>Total Submissions:<\/strong>&nbsp;8767<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Accepted:<\/strong>&nbsp;3688<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Description<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u7ed9\u51fa\u82e5\u5e72\u4e2a\u57fa\u56e0\u4e32\uff08\u7531'A','T','S','C'\u6784\u6210\uff09\uff0c\u8bf7\u627e\u51fa\u6700\u957f\u516c\u5171\u5b50\u4e32\u3002<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Input<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u7b2c\u4e00\u884c\u4e3a\u6570\u636e\u6570\u3002<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u5bf9\u6bcf\u7ec4\u6570\u636e\uff1a\u7b2c\u4e00\u884c\u4e3a\u5b57\u7b26\u4e32\u7684\u4e2a\u6570m<span style=\"font-family:'Times New Roman',Times,serif; font-size:16px\">(2 &lt;= m &lt;= 10)<\/span><\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n<span style=\"font-family:'Times New Roman',Times,serif; font-size:16px\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u4e4b\u540em\u884c\uff0c\u6bcf\u884c\u4e00\u4e2a\u57fa\u56e0\u4e32\uff08\u6709\u4e14\u4ec5\u670960\u4e2a\u5b57\u6bcd\uff09<\/span><\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Output<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u5bf9\u6bcf\u7ec4\u6570\u636e\uff0c\u627e\u51fa\u6700\u957f\u516c\u5171\u5b50\u4e32\uff0c\u5982\u679c\u957f\u5ea6\u5c0f\u4e8e3\uff0c\u8bf7\u8f93\u51fa &quot;no significant commonalities&quot; \uff0c\u5426\u5219\u8f93\u51fa\u6700\u957f\u7684\u5b57\u7b26\u4e32\uff0c\u82e5\u6709\u591a\u4e2a\u7b54\u6848\uff0c\u8f93\u51fa\u5b57\u5178\u5e8f\u6700\u5c0f\u7684\u3002<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Sample Input<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">3\n2\nGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n3\nGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATACCAGATA\nGATACTAGATACTAGATACTAGATACTAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA\nGATACCAGATACCAGATACCAGATACCAAAGGAAAGGGAAAAGGGGAAAAAGGGGGAAAA\n3\nCATCATCATCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC\nACATCATCATAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAACATCATCATTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT<\/pre>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Sample Output<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">no significant commonalities\nAGATAC\nCATCATCAT\n<\/pre>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Source<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n<a href=\"http:\/\/poj.org\/searchproblem?field=source&amp;key=South+Central+USA+2006\" style=\"text-decoration:none\">South Central USA 2006<\/a><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u679a\u4e3e\u5b57\u7b26\u4e32\u66f4\u65b0\u7b54\u6848\uff0c\u7528kmp\u7b97\u6cd5\u8fdb\u884c\u5339\u914d\u3002<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><\/span><\/p>\n<pre name=\"code\" class=\"delphi\">Program BlueJeans;\nconst\n   maxn=60;\n   maxm=10;\nvar\n   tt,i,j,k,n,m:longint;\n   a:array[1..maxm] of string;\n   next:array[1..maxn] of longint;\n   p,ans:string;\n   flag:boolean;\n\nfunction kmp(a,s:string):boolean;\nvar\n   i,j,n:longint;\nbegin\n   n:=length(a);\n\n   j:=0; next[1]:=0; i:=1;\n   while i&lt;n do\n   begin\n      if (j=0) or (a[i]=a[j]) then\n      begin\n         inc(i); inc(j);\n         if (a[i]&lt;&gt;a[j]) then next[i]:=j else next[i]:=next[j];\n      end else j:=next[j];\n   end;\n\n   j:=0; i:=0;\n   while (i&lt;=maxn) and (j&lt;=n) do\n   begin\n      if (j=0) or (a[j]=s[i]) then\n      begin\n         inc(i); inc(j);\n  \/\/       if (j=n) then exit(true);\n      end else j:=next[j];\n   end;\n\n   if j&gt;n then exit(true);\n   exit(false);\n\n\nend;\nfunction compare(a,b:string):boolean;\nvar\n   i,n,m:longint;\nbegin\n   n:=length(a); m:=length(b);\n   if (n&lt;&gt;m) then exit(n&lt;m);\n   for i:=1 to n do if (a[i]&lt;&gt;b[i]) then exit(ord(a[i])&gt;ord(b[i]));\n   exit(false);\nend;\nbegin\n   readln(tt);\n   while (tt&gt;0) do\n   begin\n      ans:='';\n      readln(m);\n      for i:=1 to m do readln(a[i]);\n\n      for i:=1 to maxn do\n         for j:=i to maxn do\n         begin\n            p:=copy(a[1],i,j-i+1);\n            flag:=false;\n            for k:=2 to m do\n            begin\n               if not(kmp(p,a[k])) then begin flag:=true; break; end;\n            end;\n            if not(flag) and (compare(ans,p)) then ans:=p;\n         end;\n\n      if length(ans)&lt;3 then writeln('no significant commonalities')\n      else writeln(ans);\n\n\n\n\n      dec(tt);\n   end;\nend.\n<\/pre>\n<\/p>\n<p>\n<\/p>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Language: Default Blue Jeans Time Limit:&nbsp;1000MS &#038;n [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[34],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-kmp"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nike0good.com\/?p=263\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good\" \/>\n<meta property=\"og:description\" content=\"Language: Default Blue Jeans Time Limit:&nbsp;1000MS &amp;n [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=263\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-14T07:40:00+00:00\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09\",\"datePublished\":\"2012-11-14T07:40:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263\"},\"wordCount\":58,\"commentCount\":0,\"keywords\":[\"KMP\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=263#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=263\",\"name\":\"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"datePublished\":\"2012-11-14T07:40:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=263\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=263#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nike0good.com\/?p=263","og_locale":"zh_CN","og_type":"article","og_title":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good","og_description":"Language: Default Blue Jeans Time Limit:&nbsp;1000MS &n [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=263","og_site_name":"nike0good","article_published_time":"2012-11-14T07:40:00+00:00","author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=263#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=263"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09","datePublished":"2012-11-14T07:40:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=263"},"wordCount":58,"commentCount":0,"keywords":["KMP"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=263#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=263","url":"https:\/\/nike0good.com\/?p=263","name":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09 - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"datePublished":"2012-11-14T07:40:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=263#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=263"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=263#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"POJ 3080(\u6700\u957f\u516c\u5171\u5b50\u4e32\uff09"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=263"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/263\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}