12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=2"><meta name="theme-color" content="#222"><meta name="generator" content="Hexo 4.2.0"><link rel="apple-touch-icon" sizes="180x180" href="/blog/blog/images/apple-touch-icon-next.png"><link rel="icon" type="image/png" sizes="32x32" href="/blog/blog/images/favicon-frog.png"><link rel="icon" type="image/png" sizes="16x16" href="/blog/blog/images/favicon-frog.png"><link rel="mask-icon" href="/blog/blog/images/logo.svg" color="#222"><link rel="stylesheet" href="/blog/css/main.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Comic Sans MS:300,300italic,400,400italic,700,700italic|Consolas:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext"><link rel="stylesheet" href="/blog/lib/font-awesome/css/font-awesome.min.css"><link rel="stylesheet" href="/blog/lib/pace/pace-theme-minimal.min.css"><script src="/blog/lib/pace/pace.min.js"></script><script id="hexo-configurations">var NexT=window.NexT||{},CONFIG={hostname:"schtonn.github.io",root:"/blog/",scheme:"Muse",version:"7.8.0",exturl:!1,sidebar:{position:"left",display:"post",padding:18,offset:12,onmobile:!1},copycode:{enable:!0,show_result:!0,style:"flat"},back2top:{enable:!0,sidebar:!1,scrollpercent:!0},bookmark:{enable:!1,color:"#222",save:"auto"},fancybox:!1,mediumzoom:!1,lazyload:!0,pangu:!1,comments:{style:"tabs",active:"valine",storage:!0,lazyload:!1,nav:null,activeClass:"valine"},algolia:{hits:{per_page:10},labels:{input_placeholder:"Search for Posts",hits_empty:"We didn't find any results for the search: ${query}",hits_stats:"${hits} results found in ${time} ms"}},localsearch:{enable:!1,trigger:"auto",top_n_per_article:1,unescape:!1,preload:!1},motion:{enable:!0,async:!1,transition:{post_block:"fadeIn",post_header:"slideDownIn",post_body:"slideDownIn",coll_header:"slideLeftIn",sidebar:"slideUpIn"}}}</script><meta name="description" content="前置知识
字符串基础操作。
引入
回文串,即 \(s=s_{rev}\),也就是本身与反转相等。
想要找到字符串 \(s\) 中最大的回文子串,很容易想到的是一种复杂度为 \(O(n^2)\) 的朴素算法,也就是对于每一个点都向外扩展。
这里介绍一种复杂度为 \(O(n)\) 的最大回文子串算法,叫做 Manacher。"><meta property="og:type" content="article"><meta property="og:title" content="Manacher"><meta property="og:url" content="https://schtonn.github.io/blog/posts/manacher/index.html"><meta property="og:site_name" content="schtonn"><meta property="og:description" content="前置知识
字符串基础操作。
引入
回文串,即 \(s=s_{rev}\),也就是本身与反转相等。
想要找到字符串 \(s\) 中最大的回文子串,很容易想到的是一种复杂度为 \(O(n^2)\) 的朴素算法,也就是对于每一个点都向外扩展。
这里介绍一种复杂度为 \(O(n)\) 的最大回文子串算法,叫做 Manacher。"><meta property="og:locale" content="en_US"><meta property="article:published_time" content="2020-06-14T14:47:39.000Z"><meta property="article:modified_time" content="2022-10-19T15:02:06.667Z"><meta property="article:author" content="Alex"><meta property="article:tag" content="string"><meta name="twitter:card" content="summary"><link rel="canonical" href="https://schtonn.github.io/blog/posts/manacher/"><script id="page-configurations">CONFIG.page={sidebar:"",isHome:!1,isPost:!0,lang:"en"}</script><title>Manacher | schtonn</title><noscript><style>.sidebar-inner,.use-motion .brand,.use-motion .collection-header,.use-motion .comments,.use-motion .menu-item,.use-motion .pagination,.use-motion .post-block,.use-motion .post-body,.use-motion .post-header{opacity:initial}.use-motion .site-subtitle,.use-motion .site-title{opacity:initial;top:initial}.use-motion .logo-line-before i{left:initial}.use-motion .logo-line-after i{right:initial}</style></noscript></head><body itemscope itemtype="http://schema.org/WebPage"><div class="container use-motion"><div class="headband"></div><header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="header-inner"><div class="site-brand-container"><div class="site-nav-toggle"><div class="toggle" aria-label="Toggle navigation bar"><span class="toggle-line toggle-line-first"></span><span class="toggle-line toggle-line-middle"></span><span class="toggle-line toggle-line-last"></span></div></div><div class="site-meta"><a href="/blog/" class="brand" rel="start"><span class="logo-line-before"><i></i></span><h1 class="site-title">schtonn</h1><span class="logo-line-after"><i></i></span></a><p class="site-subtitle" itemprop="description">schtonn</p></div><div class="site-nav-right"><div class="toggle popup-trigger"></div></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/blog/" rel="section"><i class="fa fa-fw fa-home"></i> Home</a></li><li class="menu-item menu-item-tags"><a href="/blog/tags/" rel="section"><i class="fa fa-fw fa-tags"></i> Tags</a></li><li class="menu-item menu-item-archives"><a href="/blog/archives/" rel="section"><i class="fa fa-fw fa-archive"></i> Archives</a></li><li class="menu-item menu-item-games"><a href="/blog/games/" rel="section"><i class="fa fa-fw fa-gamepad"></i> Games</a></li></ul></nav></div></header><div class="back-to-top"><i class="fa fa-arrow-up"></i> <span>0%</span></div><main class="main"><div class="main-inner"><div class="content-wrap"><div class="content post posts-expand"><article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en"><link itemprop="mainEntityOfPage" href="https://schtonn.github.io/blog/posts/manacher/"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="image" content="/blog/images/avatar.gif"><meta itemprop="name" content="Alex"><meta itemprop="description" content="blog"></span><script type="text/javascript" src="/blog/js/md5.js"></script><script></script><script>document.oncopy=function(e){window.event&&(e=window.event);try{var t=e.srcElement;return"INPUT"==t.tagName&&"text"==t.type.toLowerCase()||"TEXTAREA"==t.tagName}catch(e){return!1}}</script><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="schtonn"></span><header class="post-header"><h1 class="post-title" itemprop="name headline"> Manacher</h1><div class="post-meta"><span class="post-meta-item"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i></span> <span class="post-meta-item-text">Posted on</span> <time title="Created: 2020-Jun-14 22:47:39" itemprop="dateCreated datePublished" datetime="2020-06-14T22:47:39+08:00">2020-Jun-14</time></span><span class="post-meta-item"><span class="post-meta-item-icon"><i class="fa fa-calendar-check-o"></i></span> <span class="post-meta-item-text">Edited on</span> <time title="Modified: 2022-Oct-19 23:02:06" itemprop="dateModified" datetime="2022-10-19T23:02:06+08:00">2022-Oct-19</time></span><span class="post-meta-item"><span class="post-meta-item-icon"><i class="fa fa-comment-o"></i></span> <span class="post-meta-item-text">Valine:</span><a title="valine" href="/blog/posts/manacher/#valine-comments" itemprop="discussionUrl"><span class="post-comments-count valine-comment-count" data-xid="/blog/posts/manacher/" itemprop="commentCount"></span></a></span></div></header><div class="post-body" itemprop="articleBody"><h2 id="前置知识">前置知识</h2><p>字符串基础操作。</p><h2 id="引入">引入</h2><p>回文串,即 <span class="math inline">\(s=s_{rev}\)</span>,也就是本身与反转相等。</p><p>想要找到字符串 <span class="math inline">\(s\)</span> 中最大的回文子串,很容易想到的是一种复杂度为 <span class="math inline">\(O(n^2)\)</span> 的朴素算法,也就是对于每一个点都向外扩展。</p><p>这里介绍一种复杂度为 <span class="math inline">\(O(n)\)</span> 的最大回文子串算法,叫做 Manacher。</p><a id="more"></a><h2 id="最大回文子串">最大回文子串</h2><p>求最大回文子串,可以转化为求对于每一个位置 <code>i</code>,求以 <code>i</code> 为中心的回文串半径 <code>rad[i]</code>。</p><p>然而由于偶数长度的回文串没有实际的“中心”,所以我们需要把偶数长度全部转化为奇数长度。</p><p>方法是:在每一位字符之间添加一个填充符号,比如 <span class="math inline">\(\mathtt{\$ }\)</span>。如果原字符串是 <span class="math inline">\(\mathtt{schtonn}\)</span>,那么就转化为 <span class="math inline">\(\mathtt{\$s\$c\$h\$t\$o\$n\$n\$ }\)</span>。这样偶数长度的回文串 <span class="math inline">\(\mathtt{nn}\)</span>,就变成了奇数长度的 <span class="math inline">\(\mathtt{\$n\$n\$ }\)</span>。</p><h2 id="manacher">Manacher</h2><p>Manacher 算法维护了 <code>l</code> 和 <code>r</code>,记录<strong>右边界最靠右</strong>的回文子串的边界。</p><p>现在我们迭代 <code>i</code>,计算 <code>rad[i]</code>: - 如果 <code>i>r</code>: 直接运行朴素算法,尝试拓展 <code>rad[i]</code>,直到不符合回文串性质或者碰到边界。 - 如果 <code>i<=r</code> 这时可以尝试利用之前已计算出的结果。对于之前计算出的回文串,我们在<strong>大多数情况下</strong>认为 <code>rad[i]</code> 至少为之前计算的回文串的对应位置的值。通俗的说就是在一个大回文串内部的小回文串大小是相等的。</p><p>比如字符串 <span class="math inline">\(\mathtt{abacabaab}\)</span>,我们先将其处理成 <span class="math inline">\(\mathtt{a\$b\$a\$c\$a\$b\$a\$a\$b}\)</span>。</p><p>在第三位 <span class="math inline">\(\mathtt{b}\)</span> 前都是朴素算法:</p><p><span class="math display">\[\begin{aligned}\mathtt{\underline{\underline a\space\underline\$\space b\space\$\space a}\space\$\space c\space\$\space a\space\$\space b\space\$\space a\space\$\space a\space\$\space b}\\\mathtt{1\space1\space3\space0\space0\space0\space0\space0\space0\space0\space0\space0\space0\space0\space0\space0\space0}\end{aligned}\]</span></p><p>到了第四位 <span class="math inline">\(\mathtt{\$}\)</span>,算法认定这一位的 <code>rad</code> 至少为第二位的 <code>rad</code> 值,所以从 1 开始计算朴素算法。</p><p>经过一段时间后:</p><p><span class="math display">\[\begin{aligned}\mathtt{a\space\$\space b\space\$\space a\space\$\space c\space\$\space a\space\$\space \underline{b\space\$\space a\space\$\space a\space\$\space b}}\\\mathtt{1\space1\space3\space1\space2\space1\space7\space1\space2\space1\space4\space1\space2\space4\space2\space1\space0}\end{aligned}\]</span></p><p>这时应该计算最后一位的 <span class="math inline">\(\mathtt{b}\)</span> 了,我们根据算法看出 <code>rad</code> 至少是对应位置的 4。然而正确结果却小于四,这是因为这部分已经超出了回文串的边界。所以 <code>rad[i]</code> 应该至少为<em>到 <code>r</code> 的距离</em>和<em>对应位置 <code>rad</code> 值</em>中的最小值。</p><h2 id="代码">代码</h2><figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line">$include<span class="string">"bits/stdc++.h"</span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">int</span> len,rad[<span class="number">2000020</span>];</span><br><span class="line"><span class="keyword">int</span> maxid,maxr;</span><br><span class="line"><span class="keyword">char</span> fakes[<span class="number">1000010</span>],s[<span class="number">2000020</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>{</span><br><span class="line"> <span class="built_in">cin</span>>>fakes;</span><br><span class="line"> len=<span class="built_in">strlen</span>(fakes);</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i<=len*<span class="number">2</span>;i+=<span class="number">2</span>){</span><br><span class="line"> s[i]=<span class="string">'$'</span>;</span><br><span class="line"> s[i+<span class="number">1</span>]=fakes[(i+<span class="number">1</span>)/<span class="number">2</span>];</span><br><span class="line"> }</span><br><span class="line"> len=<span class="built_in">strlen</span>(s);</span><br><span class="line"> <span class="keyword">int</span> l=<span class="number">0</span>,r=<span class="number">-1</span>;<span class="comment">//区间边界</span></span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i<len;i++){</span><br><span class="line"> <span class="keyword">int</span> k;</span><br><span class="line"> <span class="keyword">if</span>(i>r)k=<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">else</span> k=min(rad[l+r-i],r-i);</span><br><span class="line"> <span class="keyword">while</span>(<span class="number">0</span><=i-k && i+k<len && s[i-k]==s[i+k]){</span><br><span class="line"> k++;</span><br><span class="line"> }</span><br><span class="line"> rad[i]=k--;</span><br><span class="line"> <span class="keyword">if</span>(i+k>r){</span><br><span class="line"> l=i-k;</span><br><span class="line"> r=i+k;</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">if</span>(rad[i]>maxr){</span><br><span class="line"> maxid=i;</span><br><span class="line"> maxr=rad[i];</span><br><span class="line"> }</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">int</span> ans=rad[maxid]<span class="number">-1</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=maxid-ans;i<=maxid+ans;i++){</span><br><span class="line"> <span class="keyword">if</span>(s[i]!=<span class="string">'$'</span>)<span class="built_in">cout</span><<s[i];</span><br><span class="line"> }</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">}</span><br></pre></td></tr></table></figure><h2 id="我踩的坑">我踩的坑</h2><ul><li>加上了 <span class="math inline">\(\mathtt{\$ }\)</span> 之后,数组空间需要开大两倍。</li></ul></div><div><ul class="post-copyright"><li class="post-copyright-author"> <strong>Post author:</strong> Alex</li><li class="post-copyright-link"> <strong>Post link:</strong> <a href="https://schtonn.github.io/blog/posts/manacher/" title="Manacher">https://schtonn.github.io/blog/posts/manacher/</a></li><li class="post-copyright-license"> <strong>Copyright Notice:</strong> All articles in this blog are licensed under<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i> BY-NC-SA</a> unless stating additionally.</li></ul></div><footer class="post-footer"><div class="post-tags"><a href="/blog/tags/string/" rel="tag"><i class="fa fa-tag"></i> string</a></div><div class="post-nav"><div class="post-nav-item"><a href="/blog/posts/hamilton/" rel="prev" title="哈密尔顿回路"><i class="fa fa-chevron-left"></i> 哈密尔顿回路</a></div><div class="post-nav-item"> <a href="/blog/posts/domino/" rel="next" title="各种奇奇怪怪的多米诺骨牌">各种奇奇怪怪的多米诺骨牌<i class="fa fa-chevron-right"></i></a></div></div></footer></article></div><div class="comments" id="valine-comments"></div><script>
- window.addEventListener('tabs:register', () => {
- let { activeClass } = CONFIG.comments;
- if (CONFIG.comments.storage) {
- activeClass = localStorage.getItem('comments_active') || activeClass;
- }
- if (activeClass) {
- let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
- if (activeTab) {
- activeTab.click();
- }
- }
- });
- if (CONFIG.comments.storage) {
- window.addEventListener('tabs:click', event => {
- if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
- let commentClass = event.target.classList[1];
- localStorage.setItem('comments_active', commentClass);
- });
- }
- </script></div><div class="toggle sidebar-toggle"><span class="toggle-line toggle-line-first"></span><span class="toggle-line toggle-line-middle"></span><span class="toggle-line toggle-line-last"></span></div><aside class="sidebar"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc"> Table of Contents</li><li class="sidebar-nav-overview"> Overview</li></ul><div class="post-toc-wrap sidebar-panel"><div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前置知识"><span class="nav-number">1.</span> <span class="nav-text">前置知识</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#引入"><span class="nav-number">2.</span> <span class="nav-text">引入</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#最大回文子串"><span class="nav-number">3.</span> <span class="nav-text">最大回文子串</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#manacher"><span class="nav-number">4.</span> <span class="nav-text">Manacher</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#代码"><span class="nav-number">5.</span> <span class="nav-text">代码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#我踩的坑"><span class="nav-number">6.</span> <span class="nav-text">我踩的坑</span></a></li></ol></div></div><div class="site-overview-wrap sidebar-panel"><div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person"><p class="site-author-name" itemprop="name">Alex</p><div class="site-description" itemprop="description">blog</div></div><div class="site-state-wrap motion-element"><nav class="site-state"><div class="site-state-item site-state-posts"> <a href="/blog/archives"><span class="site-state-item-count">35</span> <span class="site-state-item-name">posts</span></a></div><div class="site-state-item site-state-tags"> <a href="/blog/tags/"><span class="site-state-item-count">8</span> <span class="site-state-item-name">tags</span></a></div></nav></div><div class="links-of-author motion-element"><span class="links-of-author-item"><a href="https://github.com/schtonn" title="GitHub → https://github.com/schtonn" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i> GitHub</a></span><span class="links-of-author-item"><a href="mailto:schtonn@163.com" title="E-Mail → mailto:schtonn@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i> E-Mail</a></span></div><div class="links-of-blogroll motion-element"><div class="links-of-blogroll-title"><i class="fa fa-fw fa-link"></i> Links</div><ul class="links-of-blogroll-list"><li class="links-of-blogroll-item"> <a href="https://yonghong.github.io/" title="https://yonghong.github.io" rel="noopener" target="_blank">Yonghong</a></li><li class="links-of-blogroll-item"> <a href="https://source.unsplash.com/random/1600x900" title="https://source.unsplash.com/random/1600x900" rel="noopener" target="_blank">Background</a></li></ul><iframe width="400" height="300" frameborder="0" src="https://cdn.abowman.com/widgets/treefrog/index.html?up_bodyColor=2d2d2d&up_pattern=0&up_patternColor=000000&up_footColor=2d2d2d&up_eyeColor=3a3a3a&up_bellySize=50&up_backgroundColor=222222&up_tongueColor=2b2d2d&up_flyColor=3a3a3a&up_releaseFly=0"></iframe></div></div></div></aside><div id="sidebar-dimmer"></div></div></main><footer class="footer"><div class="footer-inner"><div class="copyright"> © 2019 – <span itemprop="copyrightYear">2023</span><span class="with-love"><i class="fa fa-user"></i></span> <span class="author" itemprop="copyrightHolder">Alexander</span></div></div></footer></div><script src="/blog/lib/anime.min.js"></script><script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script><script src="/blog/lib/velocity/velocity.min.js"></script><script src="/blog/lib/velocity/velocity.ui.min.js"></script><script src="/blog/js/utils.js"></script><script src="/blog/js/motion.js"></script><script src="/blog/js/schemes/muse.js"></script><script src="/blog/js/next-boot.js"></script><script>!function(){var t=document.createElement("script"),e=window.location.protocol.split(":")[0];t.src="https"===e?"https://zz.bdstatic.com/linksubmit/push.js":"http://push.zhanzhang.baidu.com/push.js";var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(t,s)}()</script><script>
- if (typeof MathJax === 'undefined') {
- window.MathJax = {
- loader: {
- load: ['[tex]/mhchem'],
- source: {
- '[tex]/amsCd': '[tex]/amscd',
- '[tex]/AMScd': '[tex]/amscd'
- }
- },
- tex: {
- inlineMath: {'[+]': [['$', '$']]},
- packages: {'[+]': ['mhchem']},
- tags: 'ams'
- },
- options: {
- renderActions: {
- findScript: [10, doc => {
- document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
- const display = !!node.type.match(/; *mode=display/);
- const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
- const text = document.createTextNode('');
- node.parentNode.replaceChild(text, node);
- math.start = {node: text, delim: '', n: 0};
- math.end = {node: text, delim: '', n: 0};
- doc.math.push(math);
- });
- }, '', false],
- insertedScript: [200, () => {
- document.querySelectorAll('mjx-container').forEach(node => {
- let target = node.parentNode;
- if (target.nodeName.toLowerCase() === 'li') {
- target.parentNode.classList.add('has-jax');
- }
- });
- }, '', false]
- }
- }
- };
- (function () {
- var script = document.createElement('script');
- script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
- script.defer = true;
- document.head.appendChild(script);
- })();
- } else {
- MathJax.startup.document.state(0);
- MathJax.texReset();
- MathJax.typeset();
- }
- </script><script>
- NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
- NexT.utils.getScript('https://cdn.jsdelivr.net/npm/valine@1/dist/Valine.min.js', () => {
- var GUEST = ['nick', 'mail', 'link'];
- var guest = 'nick,mail';
- guest = guest.split(',').filter(item => {
- return GUEST.includes(item);
- });
- new Valine({
- el : '#valine-comments',
- verify : false,
- notify : false,
- appId : 'BmologYYnRqCv0SLHDeDdA17-gzGzoHsz',
- appKey : 'w9mVebFMdCmY6Nh9vfcBGaGt',
- placeholder: "Comment...",
- avatar : 'mp',
- meta : guest,
- pageSize : '10' || 10,
- visitor : false,
- lang : 'en' || 'zh-cn',
- path : location.pathname,
- recordIP : true,
- serverURLs : ''
- });
- }, window.Valine);
- });
- </script></body></html>
|