index.html 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
  6. <meta name="theme-color" content="#222">
  7. <meta name="generator" content="Hexo 4.2.0">
  8. <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  9. <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  10. <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  11. <link rel="mask-icon" href="/images/logo.svg" color="#222">
  12. <link rel="stylesheet" href="/css/main.css">
  13. <link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">
  14. <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  15. <script src="/lib/pace/pace.min.js"></script>
  16. <script id="hexo-configurations">
  17. var NexT = window.NexT || {};
  18. var CONFIG = {"hostname":"schtonn.github.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"flat"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"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":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  19. </script>
  20. <meta name="description" content="前置知识 必备:存图方式(邻接表,邻接矩阵),dfs序。 维护:线段树、树状数组、BST。 不会的快进入链接学习吧! 引入 树链剖分,简单来说就是把树分割成链,然后维护每一条链。一般的维护算法有线段树,树状数组和BST。复杂度为O(logn)O(log n)O(logn)。">
  21. <meta property="og:type" content="article">
  22. <meta property="og:title" content="树链剖分">
  23. <meta property="og:url" content="https://schtonn.github.io/posts/tree-link/index.html">
  24. <meta property="og:site_name" content="Alex&#39;s Blog">
  25. <meta property="og:description" content="前置知识 必备:存图方式(邻接表,邻接矩阵),dfs序。 维护:线段树、树状数组、BST。 不会的快进入链接学习吧! 引入 树链剖分,简单来说就是把树分割成链,然后维护每一条链。一般的维护算法有线段树,树状数组和BST。复杂度为O(logn)O(log n)O(logn)。">
  26. <meta property="og:locale" content="en_US">
  27. <meta property="og:image" content="https://img-blog.csdnimg.cn/20191228195815530.png">
  28. <meta property="article:published_time" content="2020-03-01T14:41:02.000Z">
  29. <meta property="article:modified_time" content="2020-03-29T07:59:54.282Z">
  30. <meta property="article:author" content="Alex">
  31. <meta property="article:tag" content="graph">
  32. <meta name="twitter:card" content="summary">
  33. <meta name="twitter:image" content="https://img-blog.csdnimg.cn/20191228195815530.png">
  34. <link rel="canonical" href="https://schtonn.github.io/posts/tree-link/">
  35. <script id="page-configurations">
  36. // https://hexo.io/docs/variables.html
  37. CONFIG.page = {
  38. sidebar: "",
  39. isHome : false,
  40. isPost : true,
  41. lang : 'en'
  42. };
  43. </script>
  44. <title>树链剖分 | Alex's Blog</title>
  45. <noscript>
  46. <style>
  47. .use-motion .brand,
  48. .use-motion .menu-item,
  49. .sidebar-inner,
  50. .use-motion .post-block,
  51. .use-motion .pagination,
  52. .use-motion .comments,
  53. .use-motion .post-header,
  54. .use-motion .post-body,
  55. .use-motion .collection-header { opacity: initial; }
  56. .use-motion .site-title,
  57. .use-motion .site-subtitle {
  58. opacity: initial;
  59. top: initial;
  60. }
  61. .use-motion .logo-line-before i { left: initial; }
  62. .use-motion .logo-line-after i { right: initial; }
  63. </style>
  64. </noscript>
  65. </head>
  66. <body itemscope itemtype="http://schema.org/WebPage">
  67. <div class="container use-motion">
  68. <div class="headband"></div>
  69. <header class="header" itemscope itemtype="http://schema.org/WPHeader">
  70. <div class="header-inner"><div class="site-brand-container">
  71. <div class="site-nav-toggle">
  72. <div class="toggle" aria-label="Toggle navigation bar">
  73. <span class="toggle-line toggle-line-first"></span>
  74. <span class="toggle-line toggle-line-middle"></span>
  75. <span class="toggle-line toggle-line-last"></span>
  76. </div>
  77. </div>
  78. <div class="site-meta">
  79. <a href="/" class="brand" rel="start">
  80. <span class="logo-line-before"><i></i></span>
  81. <h1 class="site-title">Alex's Blog</h1>
  82. <span class="logo-line-after"><i></i></span>
  83. </a>
  84. <p class="site-subtitle" itemprop="description">Middle school OIer</p>
  85. </div>
  86. <div class="site-nav-right">
  87. <div class="toggle popup-trigger">
  88. </div>
  89. </div>
  90. </div>
  91. <nav class="site-nav">
  92. <ul id="menu" class="menu">
  93. <li class="menu-item menu-item-home">
  94. <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>
  95. </li>
  96. <li class="menu-item menu-item-tags">
  97. <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>Tags</a>
  98. </li>
  99. <li class="menu-item menu-item-archives">
  100. <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>
  101. </li>
  102. <li class="menu-item menu-item-games">
  103. <a href="/games/" rel="section"><i class="fa fa-fw fa-gamepad"></i>Games</a>
  104. </li>
  105. <li class="menu-item menu-item-sans">
  106. <a href="/sans/" rel="section"><i class="fa fa-fw fa-heart"></i>sans</a>
  107. </li>
  108. </ul>
  109. </nav>
  110. </div>
  111. </header>
  112. <div class="back-to-top">
  113. <i class="fa fa-arrow-up"></i>
  114. <span>0%</span>
  115. </div>
  116. <div class="reading-progress-bar"></div>
  117. <main class="main">
  118. <div class="main-inner">
  119. <div class="content-wrap">
  120. <div class="content post posts-expand">
  121. <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
  122. <link itemprop="mainEntityOfPage" href="https://schtonn.github.io/posts/tree-link/">
  123. <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
  124. <meta itemprop="image" content="/images/avatar.gif">
  125. <meta itemprop="name" content="Alex">
  126. <meta itemprop="description" content="The blog of a middle school OIer">
  127. </span>
  128. <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
  129. <meta itemprop="name" content="Alex's Blog">
  130. </span>
  131. <header class="post-header">
  132. <h1 class="post-title" itemprop="name headline">
  133. 树链剖分
  134. </h1>
  135. <div class="post-meta">
  136. <span class="post-meta-item">
  137. <span class="post-meta-item-icon">
  138. <i class="fa fa-calendar-o"></i>
  139. </span>
  140. <span class="post-meta-item-text">Posted on</span>
  141. <time title="Created: 2020-Mar-01 22:41:02" itemprop="dateCreated datePublished" datetime="2020-03-01T22:41:02+08:00">2020-Mar-01</time>
  142. </span>
  143. <span class="post-meta-item">
  144. <span class="post-meta-item-icon">
  145. <i class="fa fa-calendar-check-o"></i>
  146. </span>
  147. <span class="post-meta-item-text">Edited on</span>
  148. <time title="Modified: 2020-Mar-29 15:59:54" itemprop="dateModified" datetime="2020-03-29T15:59:54+08:00">2020-Mar-29</time>
  149. </span>
  150. <span id="/posts/tree-link/" class="post-meta-item leancloud_visitors" data-flag-title="树链剖分" title="Views">
  151. <span class="post-meta-item-icon">
  152. <i class="fa fa-eye"></i>
  153. </span>
  154. <span class="post-meta-item-text">Views: </span>
  155. <span class="leancloud-visitors-count"></span>
  156. </span>
  157. <span class="post-meta-item">
  158. <span class="post-meta-item-icon">
  159. <i class="fa fa-comment-o"></i>
  160. </span>
  161. <span class="post-meta-item-text">Valine: </span>
  162. <a title="valine" href="/posts/tree-link/#valine-comments" itemprop="discussionUrl">
  163. <span class="post-comments-count valine-comment-count" data-xid="/posts/tree-link/" itemprop="commentCount"></span>
  164. </a>
  165. </span>
  166. </div>
  167. </header>
  168. <div class="post-body" itemprop="articleBody">
  169. <h3 id="前置知识"><a class="markdownIt-Anchor" href="#前置知识"></a> 前置知识</h3>
  170. <p>必备:存图方式(<a href="http://baidu.physton.com/?q=%E9%82%BB%E6%8E%A5%E8%A1%A8" target="_blank" rel="noopener" title="简单">邻接表</a>,<a href="http://baidu.physton.com/?q=%E9%82%BB%E6%8E%A5%E7%9F%A9%E9%98%B5" target="_blank" rel="noopener" title="都太简单了,没有一个打得过的">邻接矩阵</a>),<a href="http://baidu.physton.com/?q=dfs%E5%BA%8F" target="_blank" rel="noopener">dfs序</a>。<br />
  171. 维护:<a href="http://baidu.physton.com/?q=%E7%BA%BF%E6%AE%B5%E6%A0%91" target="_blank" rel="noopener">线段树</a>、<a href="http://baidu.physton.com/?q=%E6%A0%91%E7%8A%B6%E6%95%B0%E7%BB%84" target="_blank" rel="noopener">树状数组</a>、<a href="http://baidu.physton.com/?q=BST" target="_blank" rel="noopener">BST</a>。<br />
  172. 不会的快进入链接学习吧!</p>
  173. <h3 id="引入"><a class="markdownIt-Anchor" href="#引入"></a> 引入</h3>
  174. <p>树链剖分,简单来说就是把树分割成链,然后维护每一条链。一般的维护算法有线段树,树状数组和BST。复杂度为<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>O</mi><mo stretchy="false">(</mo><mi>l</mi><mi>o</mi><mi>g</mi><mi>n</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">O(log n)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">O</span><span class="mopen">(</span><span class="mord mathdefault" style="margin-right:0.01968em;">l</span><span class="mord mathdefault">o</span><span class="mord mathdefault" style="margin-right:0.03588em;">g</span><span class="mord mathdefault">n</span><span class="mclose">)</span></span></span></span>。</p>
  175. <a id="more"></a>
  176. <h3 id="剖分方式"><a class="markdownIt-Anchor" href="#剖分方式"></a> 剖分方式</h3>
  177. <p>对于每一个节点,它的子节点中<strong>子树的节点数最大的</strong>为重儿子,连接到重儿子的边称为重边。例如:<br />
  178. <img data-src="https://img-blog.csdnimg.cn/20191228195815530.png" alt="" /><br />
  179. 加粗节点为重儿子。<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>4</mn></mrow><annotation encoding="application/x-tex">4</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">4</span></span></span></span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>5</mn></mrow><annotation encoding="application/x-tex">5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">5</span></span></span></span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>6</mn></mrow><annotation encoding="application/x-tex">6</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">6</span></span></span></span>节点的重量都一样,所以你想上哪个成为重儿子那个就是重儿子。除重儿子和重边外的节点和边均为轻儿子或轻边。根不是重儿子也不是轻儿子 <s>,有脑子的人都会想一想,它根本就不是什么儿子!</s> 。<br />
  180. 以轻儿子或者根为起点的,由重边连接的一条连续的链称为重链。特别地,若一个叶子结点是轻儿子,那么便有一条以该叶子结点为起点的长度为1的重链。上图中,<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>1</mn><mo>−</mo><mn>3</mn><mo>−</mo><mn>7</mn><mo>−</mo><mn>9</mn></mrow><annotation encoding="application/x-tex">1-3-7-9</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.72777em;vertical-align:-0.08333em;"></span><span class="mord">1</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.72777em;vertical-align:-0.08333em;"></span><span class="mord">3</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.72777em;vertical-align:-0.08333em;"></span><span class="mord">7</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right:0.2222222222222222em;"></span></span><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">9</span></span></span></span>是一条重链,<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>6</mn></mrow><annotation encoding="application/x-tex">6</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.64444em;vertical-align:0em;"></span><span class="mord">6</span></span></span></span>一个节点也是一条重链。</p>
  181. <h3 id="预处理"><a class="markdownIt-Anchor" href="#预处理"></a> 预处理</h3>
  182. <p>树链剖分的预处理本质上就是2个dfs。</p>
  183. <h4 id="dfs-no1"><a class="markdownIt-Anchor" href="#dfs-no1"></a> dfs NO.1</h4>
  184. <p>一共完成四项任务。</p>
  185. <ul>
  186. <li>标记节点深度:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>d</mi><mi>e</mi><mi>p</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">dep[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">d</span><span class="mord mathdefault">e</span><span class="mord mathdefault">p</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  187. <li>标记节点的父节点:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>f</mi><mi>a</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">fa[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.10764em;">f</span><span class="mord mathdefault">a</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  188. <li>标记节点的子树大小:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>s</mi><mi>i</mi><mi>z</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">siz[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">s</span><span class="mord mathdefault">i</span><span class="mord mathdefault" style="margin-right:0.04398em;">z</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  189. <li>标记节点的重儿子编号:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>s</mi><mi>o</mi><mi>n</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">son[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">s</span><span class="mord mathdefault">o</span><span class="mord mathdefault">n</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  190. </ul>
  191. <p>代码:</p>
  192. <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></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs_1</span><span class="params">(<span class="keyword">int</span> u,<span class="keyword">int</span> f)</span></span>&#123;</span><br><span class="line"> siz[u]=<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">int</span> maxson=<span class="number">-1</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=head[u];i!=<span class="number">-1</span>;i=edge[i].nxt)&#123;</span><br><span class="line"> <span class="keyword">int</span> v=edge[i].v;</span><br><span class="line"> <span class="keyword">if</span>(v==f) <span class="keyword">continue</span>;</span><br><span class="line"> fa[v]=u;</span><br><span class="line"> dep[v]=dep[u]+<span class="number">1</span>;</span><br><span class="line"> dfs_1(v,u);</span><br><span class="line"> siz[u]+=siz[v];</span><br><span class="line"> <span class="keyword">if</span>(siz[v]&gt;siz[son[u]])son[u]=v;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
  193. <h4 id="dfs-no2"><a class="markdownIt-Anchor" href="#dfs-no2"></a> dfs NO.2</h4>
  194. <p>完成三项任务。</p>
  195. <ul>
  196. <li>标记dfs序(先重后轻):<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>i</mi><mi>d</mi><mi>x</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">idx[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">i</span><span class="mord mathdefault">d</span><span class="mord mathdefault">x</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  197. <li>标记dfs序对应的节点:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>r</mi><mi>n</mi><mi>k</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">rnk[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault" style="margin-right:0.02778em;">r</span><span class="mord mathdefault">n</span><span class="mord mathdefault" style="margin-right:0.03148em;">k</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  198. <li>标记节点所在重链的顶端:<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>t</mi><mi>o</mi><mi>p</mi><mo stretchy="false">[</mo><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">top[]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathdefault">t</span><span class="mord mathdefault">o</span><span class="mord mathdefault">p</span><span class="mopen">[</span><span class="mclose">]</span></span></span></span></li>
  199. </ul>
  200. <p>代码:</p>
  201. <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></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs_2</span><span class="params">(<span class="keyword">int</span> u,<span class="keyword">int</span> tp)</span></span>&#123;</span><br><span class="line"> idx[u]=++dfn;</span><br><span class="line"> rnk[dfn]=a[u];</span><br><span class="line"> top[u]=tp;</span><br><span class="line"> <span class="keyword">if</span>(!son[u])<span class="keyword">return</span>;</span><br><span class="line"> dfs_2(son[u],tp);</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=head[u];i!=<span class="number">-1</span>;i=edge[i].nxt)&#123;</span><br><span class="line"> <span class="keyword">if</span>(!idx[edge[i].v])&#123;</span><br><span class="line"> dfs_2(edge[i].v,edge[i].v);</span><br><span class="line"> &#125;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
  202. <h3 id="维护"><a class="markdownIt-Anchor" href="#维护"></a> 维护</h3>
  203. <p>这里以洛谷的<a href="https://www.luogu.com.cn/problem/P3384" target="_blank" rel="noopener">P3384</a>为例<br />
  204. 要求维护四种操作:</p>
  205. <ul>
  206. <li>操作1: 格式: 1 x y z 表示将树从x到y结点最短路径上所有节点的值都加上z</li>
  207. <li>操作2: 格式: 2 x y 表示求树从x到y结点最短路径上所有节点的值之和</li>
  208. <li>操作3: 格式: 3 x z 表示将以x为根节点的子树内所有节点值都加上z</li>
  209. <li>操作4: 格式: 4 x 表示求以x为根节点的子树内所有节点值之和</li>
  210. </ul>
  211. <ol>
  212. <li>
  213. <p>要处理两点间的路径时:<br />
  214. 首先找到两个节点中较深的那个点,然后将对该店所在链进行处理,并将该点移动至所在链顶端节点<strong>的父节点</strong>。因为是按照轻重边为优先级做的dfs,所以一条链上的编号一定是连续的。<br />
  215. 循环执行直到两个点在一条链上,这时再处理两个点之间的区间即可。</p>
  216. </li>
  217. <li>
  218. <p>要处理一个点的子树时:<br />
  219. 因为是dfs序,所以子树的dfs序一定是连续的区间,直接处理该区间即可。</p>
  220. </li>
  221. </ol>
  222. <p>因为都是处理区间,所以用线段树维护。</p>
  223. <h3 id="完整代码"><a class="markdownIt-Anchor" href="#完整代码"></a> 完整代码</h3>
  224. <p>因为题目中还有一个毒瘤%p,所以代码显得很繁杂。</p>
  225. <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><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">"bits/stdc++.h"</span></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">const</span> <span class="keyword">int</span> N=<span class="number">2000100</span>;</span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> lson id&lt;&lt;1</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> rson id&lt;&lt;1|1</span></span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="title">read</span><span class="params">()</span></span>&#123;</span><br><span class="line"> <span class="keyword">int</span> c=<span class="number">1</span>,q=<span class="number">0</span>;<span class="keyword">char</span> ch=<span class="string">' '</span>;</span><br><span class="line"> <span class="keyword">while</span>(ch!=<span class="string">'-'</span>&amp;&amp;(ch&lt;<span class="string">'0'</span>||ch&gt;<span class="string">'9'</span>))ch=getchar();</span><br><span class="line"> <span class="keyword">if</span>(ch==<span class="string">'-'</span>)c=<span class="number">-1</span>,ch=getchar();</span><br><span class="line"> <span class="keyword">while</span>(ch&gt;=<span class="string">'0'</span>&amp;&amp;ch&lt;=<span class="string">'9'</span>)q=q*<span class="number">10</span>+ch-<span class="string">'0'</span>,ch=getchar();</span><br><span class="line"> <span class="keyword">return</span> c*q;</span><br><span class="line">&#125;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">node</span>&#123;</span></span><br><span class="line"> <span class="keyword">int</span> u,v,nxt;</span><br><span class="line">&#125;e[N];</span><br><span class="line"><span class="keyword">int</span> head[N];</span><br><span class="line"><span class="keyword">int</span> tot=<span class="number">1</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">Tree</span>&#123;</span></span><br><span class="line"> <span class="keyword">int</span> l,r,c,siz,f;</span><br><span class="line">&#125;t[N];</span><br><span class="line"><span class="keyword">int</span> n,m,root,p,dfn=<span class="number">0</span>,rnk[N],a[N];</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="keyword">void</span> <span class="title">add</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>&#123;</span><br><span class="line"> e[tot].u=x;</span><br><span class="line"> e[tot].v=y;</span><br><span class="line"> e[tot].nxt=head[x];</span><br><span class="line"> head[x]=tot++;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">int</span> dep[N],fa[N],son[N],siz[N],top[N],idx[N];</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs_1</span><span class="params">(<span class="keyword">int</span> u,<span class="keyword">int</span> f)</span></span>&#123;</span><br><span class="line"> siz[u]=<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=head[u];i;i=e[i].nxt)&#123;</span><br><span class="line"> <span class="keyword">int</span> v=e[i].v;</span><br><span class="line"> <span class="keyword">if</span>(v==f) <span class="keyword">continue</span>;</span><br><span class="line"> fa[v]=u;</span><br><span class="line"> dep[v]=dep[u]+<span class="number">1</span>;</span><br><span class="line"> dfs_1(v,u);</span><br><span class="line"> siz[u]+=siz[v];</span><br><span class="line"> <span class="keyword">if</span>(siz[v]&gt;siz[son[u]])son[u]=v;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">update</span><span class="params">(<span class="keyword">int</span> id)</span></span>&#123;</span><br><span class="line"> t[id].c=(t[lson].c+t[rson].c+p)%p;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">Build</span><span class="params">(<span class="keyword">int</span> id,<span class="keyword">int</span> L,<span class="keyword">int</span> R)</span></span>&#123;</span><br><span class="line"> t[id].l=L;t[id].r=R;t[id].siz=R-L+<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">if</span>(L==R)&#123;</span><br><span class="line"> t[id].c=rnk[L];</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">int</span> mid=(L+R)&gt;&gt;<span class="number">1</span>;</span><br><span class="line"> Build(lson,L,mid);</span><br><span class="line"> Build(rson,mid+<span class="number">1</span>,R);</span><br><span class="line"> update(id);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">dfs_2</span><span class="params">(<span class="keyword">int</span> u,<span class="keyword">int</span> tp)</span></span>&#123;</span><br><span class="line"> idx[u]=++dfn;</span><br><span class="line"> rnk[dfn]=a[u];</span><br><span class="line"> top[u]=tp;</span><br><span class="line"> <span class="keyword">if</span>(!son[u])<span class="keyword">return</span>;</span><br><span class="line"> dfs_2(son[u],tp);</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=head[u];i;i=e[i].nxt)&#123;</span><br><span class="line"> <span class="keyword">if</span>(!idx[e[i].v])&#123;</span><br><span class="line"> dfs_2(e[i].v,e[i].v);</span><br><span class="line"> &#125;</span><br><span class="line"> &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">pushdown</span><span class="params">(<span class="keyword">int</span> id)</span></span>&#123;</span><br><span class="line"> <span class="keyword">if</span>(!t[id].f) <span class="keyword">return</span> ;</span><br><span class="line"> t[lson].c=(t[lson].c+t[lson].siz*t[id].f)%p;</span><br><span class="line"> t[rson].c=(t[rson].c+t[rson].siz*t[id].f)%p;</span><br><span class="line"> t[lson].f=(t[lson].f+t[id].f)%p;</span><br><span class="line"> t[rson].f=(t[rson].f+t[id].f)%p;</span><br><span class="line"> t[id].f=<span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">addroute</span><span class="params">(<span class="keyword">int</span> id,<span class="keyword">int</span> L,<span class="keyword">int</span> R,<span class="keyword">int</span> c)</span></span>&#123;</span><br><span class="line"> <span class="keyword">if</span>(L&lt;=t[id].l&amp;&amp;t[id].r&lt;=R)&#123;</span><br><span class="line"> t[id].c+=t[id].siz*c;</span><br><span class="line"> t[id].f+=c;</span><br><span class="line"> <span class="keyword">return</span>;</span><br><span class="line"> &#125;</span><br><span class="line"> pushdown(id);</span><br><span class="line"> <span class="keyword">int</span> mid=(t[id].l+t[id].r)&gt;&gt;<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">if</span>(L&lt;=mid)addroute(lson,L,R,c);</span><br><span class="line"> <span class="keyword">if</span>(R&gt;mid)addroute(rson,L,R,c);</span><br><span class="line"> update(id);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">addtree</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y,<span class="keyword">int</span> c)</span></span>&#123;</span><br><span class="line"> <span class="keyword">while</span>(top[x]!=top[y])&#123;</span><br><span class="line"> <span class="keyword">if</span>(dep[top[x]]&lt;dep[top[y]])swap(x,y);</span><br><span class="line"> addroute(<span class="number">1</span>,idx[top[x]],idx[x],c);</span><br><span class="line"> x=fa[top[x]];</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">if</span>(dep[x]&gt;dep[y])swap(x,y);</span><br><span class="line"> addroute(<span class="number">1</span>,idx[x],idx[y],c);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">sumroute</span><span class="params">(<span class="keyword">int</span> id,<span class="keyword">int</span> L,<span class="keyword">int</span> R)</span></span>&#123;</span><br><span class="line"> <span class="keyword">int</span> ans=<span class="number">0</span>;</span><br><span class="line"> <span class="keyword">if</span>(L&lt;=t[id].l&amp;&amp;t[id].r&lt;=R)</span><br><span class="line"> <span class="keyword">return</span> t[id].c;</span><br><span class="line"> pushdown(id);</span><br><span class="line"> <span class="keyword">int</span> mid=(t[id].l+t[id].r)&gt;&gt;<span class="number">1</span>;</span><br><span class="line"> <span class="keyword">if</span>(L&lt;=mid) ans=(ans+sumroute(lson,L,R))%p;</span><br><span class="line"> <span class="keyword">if</span>(R&gt;mid) ans=(ans+sumroute(rson,L,R))%p;</span><br><span class="line"> <span class="keyword">return</span> ans;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">treesum</span><span class="params">(<span class="keyword">int</span> x,<span class="keyword">int</span> y)</span></span>&#123;</span><br><span class="line"> <span class="keyword">int</span> ans=<span class="number">0</span>;</span><br><span class="line"> <span class="keyword">while</span>(top[x]!=top[y])&#123;</span><br><span class="line"> <span class="keyword">if</span>(dep[top[x]]&lt;dep[top[y]]) swap(x,y);</span><br><span class="line"> ans=(ans+sumroute(<span class="number">1</span>,idx[top[x]],idx[x]))%p;</span><br><span class="line"> x=fa[top[x]];</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">if</span>(dep[x]&gt;dep[y]) swap(x,y);</span><br><span class="line"> ans=(ans+sumroute(<span class="number">1</span>,idx[x],idx[y]))%p;</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,ans);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line"> n=read();m=read();root=read();p=read();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++) a[i]=read();</span><br><span class="line"> <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n<span class="number">-1</span>;i++)&#123;</span><br><span class="line"> <span class="keyword">int</span> x=read(),y=read();</span><br><span class="line"> add(x,y);add(y,x);</span><br><span class="line"> &#125;</span><br><span class="line"> dfs_1(root,root);</span><br><span class="line"> dfs_2(root,root);</span><br><span class="line"> Build(<span class="number">1</span>,<span class="number">1</span>,n);</span><br><span class="line"> <span class="keyword">while</span>(m--)&#123;</span><br><span class="line"> <span class="keyword">int</span> op=read(),x,y,z;</span><br><span class="line"> <span class="keyword">if</span>(op==<span class="number">1</span>)&#123; </span><br><span class="line"> x=read();y=read();z=read();z=z%p;</span><br><span class="line"> addtree(x,y,z);</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">else</span> <span class="keyword">if</span>(op==<span class="number">2</span>)&#123;</span><br><span class="line"> x=read();y=read();</span><br><span class="line"> treesum(x,y);</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">else</span> <span class="keyword">if</span>(op==<span class="number">3</span>)&#123;</span><br><span class="line"> x=read(),z=read();</span><br><span class="line"> addroute(<span class="number">1</span>,idx[x],idx[x]+siz[x]<span class="number">-1</span>,z%p);</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">else</span> <span class="keyword">if</span>(op==<span class="number">4</span>)&#123;</span><br><span class="line"> x=read();</span><br><span class="line"> <span class="built_in">printf</span>(<span class="string">"%d\n"</span>,sumroute(<span class="number">1</span>,idx[x],idx[x]+siz[x]<span class="number">-1</span>));</span><br><span class="line"> &#125;</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
  226. <p>完结撒花~~</p>
  227. </div>
  228. <div>
  229. <ul class="post-copyright">
  230. <li class="post-copyright-author">
  231. <strong>Post author: </strong>Alex
  232. </li>
  233. <li class="post-copyright-link">
  234. <strong>Post link: </strong>
  235. <a href="https://schtonn.github.io/posts/tree-link/" title="树链剖分">https://schtonn.github.io/posts/tree-link/</a>
  236. </li>
  237. <li class="post-copyright-license">
  238. <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.
  239. </li>
  240. </ul>
  241. </div>
  242. <footer class="post-footer">
  243. <div class="post-tags">
  244. <a href="/tags/graph/" rel="tag"><i class="fa fa-tag"></i> graph</a>
  245. </div>
  246. <div class="post-nav">
  247. <div class="post-nav-item">
  248. <a href="/posts/plan/" rel="prev" title="plan">
  249. <i class="fa fa-chevron-left"></i> plan
  250. </a></div>
  251. <div class="post-nav-item">
  252. <a href="/posts/union-find/" rel="next" title="并查集">
  253. 并查集 <i class="fa fa-chevron-right"></i>
  254. </a></div>
  255. </div>
  256. </footer>
  257. </article>
  258. </div>
  259. <div class="comments" id="valine-comments"></div>
  260. <script>
  261. window.addEventListener('tabs:register', () => {
  262. let { activeClass } = CONFIG.comments;
  263. if (CONFIG.comments.storage) {
  264. activeClass = localStorage.getItem('comments_active') || activeClass;
  265. }
  266. if (activeClass) {
  267. let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
  268. if (activeTab) {
  269. activeTab.click();
  270. }
  271. }
  272. });
  273. if (CONFIG.comments.storage) {
  274. window.addEventListener('tabs:click', event => {
  275. if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
  276. let commentClass = event.target.classList[1];
  277. localStorage.setItem('comments_active', commentClass);
  278. });
  279. }
  280. </script>
  281. </div>
  282. <div class="toggle sidebar-toggle">
  283. <span class="toggle-line toggle-line-first"></span>
  284. <span class="toggle-line toggle-line-middle"></span>
  285. <span class="toggle-line toggle-line-last"></span>
  286. </div>
  287. <aside class="sidebar">
  288. <div class="sidebar-inner">
  289. <ul class="sidebar-nav motion-element">
  290. <li class="sidebar-nav-toc">
  291. Table of Contents
  292. </li>
  293. <li class="sidebar-nav-overview">
  294. Overview
  295. </li>
  296. </ul>
  297. <!--noindex-->
  298. <div class="post-toc-wrap sidebar-panel">
  299. <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#前置知识"><span class="nav-number">1.</span> <span class="nav-text"> 前置知识</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#引入"><span class="nav-number">2.</span> <span class="nav-text"> 引入</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#剖分方式"><span class="nav-number">3.</span> <span class="nav-text"> 剖分方式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#预处理"><span class="nav-number">4.</span> <span class="nav-text"> 预处理</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#dfs-no1"><span class="nav-number">4.1.</span> <span class="nav-text"> dfs NO.1</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#dfs-no2"><span class="nav-number">4.2.</span> <span class="nav-text"> dfs NO.2</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#维护"><span class="nav-number">5.</span> <span class="nav-text"> 维护</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#完整代码"><span class="nav-number">6.</span> <span class="nav-text"> 完整代码</span></a></li></ol></div>
  300. </div>
  301. <!--/noindex-->
  302. <div class="site-overview-wrap sidebar-panel">
  303. <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  304. <p class="site-author-name" itemprop="name">Alex</p>
  305. <div class="site-description" itemprop="description">The blog of a middle school OIer</div>
  306. </div>
  307. <div class="site-state-wrap motion-element">
  308. <nav class="site-state">
  309. <div class="site-state-item site-state-posts">
  310. <a href="/archives">
  311. <span class="site-state-item-count">10</span>
  312. <span class="site-state-item-name">posts</span>
  313. </a>
  314. </div>
  315. <div class="site-state-item site-state-tags">
  316. <a href="/tags/">
  317. <span class="site-state-item-count">4</span>
  318. <span class="site-state-item-name">tags</span></a>
  319. </div>
  320. </nav>
  321. </div>
  322. <div class="links-of-author motion-element">
  323. <span class="links-of-author-item">
  324. <a href="https://github.com/schtonn" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;schtonn" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
  325. </span>
  326. <span class="links-of-author-item">
  327. <a href="mailto:m18519511495@163.com" title="E-Mail → mailto:m18519511495@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
  328. </span>
  329. </div>
  330. <div class="links-of-blogroll motion-element">
  331. <div class="links-of-blogroll-title">
  332. <i class="fa fa-fw fa-link"></i>
  333. Links
  334. </div>
  335. <ul class="links-of-blogroll-list">
  336. <li class="links-of-blogroll-item">
  337. <a href="https://yonghong.github.io/" title="https:&#x2F;&#x2F;yonghong.github.io" rel="noopener" target="_blank">Yonghong</a>
  338. </li>
  339. <li class="links-of-blogroll-item">
  340. <a href="https://source.unsplash.com/random/1600x900" title="https:&#x2F;&#x2F;source.unsplash.com&#x2F;random&#x2F;1600x900" rel="noopener" target="_blank">Background</a>
  341. </li>
  342. </ul>
  343. </div>
  344. </div>
  345. <div id="treefrog" style="text-align: center;margin-top: 18px;">
  346. <object type="application/x-shockwave-flash" style="outline:none;" data="/flash/treefrog.swf?up_bodyColor=444444&up_pattern=0&up_flyColor=777777&up_tongueColor=555555&up_patternColor=000000&up_releaseFly=0&up_frogName=Froggie&up_backgroundImage=http://&up_bellySize=.5&up_footColor=444444&up_eyeColor=444444&up_backgroundColor=222222&" width="300" height="600"><param name="movie" value="http://cdn.abowman.com/widgets/treefrog/treefrog.swf?up_bodyColor=444444&up_pattern=0&up_flyColor=777777&up_tongueColor=555555&up_patternColor=000000&up_releaseFly=0&up_frogName=Froggie&up_backgroundImage=http://&up_bellySize=.5&up_footColor=444444&up_eyeColor=444444&up_backgroundColor=222222&"></param><param name="AllowScriptAccess" value="always"></param><param name="wmode" value="opaque"></param><param name="scale" value="noscale"/><param name="salign" value="tl"/></object>
  347. </div>
  348. </div>
  349. </aside>
  350. <div id="sidebar-dimmer"></div>
  351. </div>
  352. </main>
  353. <footer class="footer">
  354. <div class="footer-inner">
  355. <div class="copyright">
  356. &copy;
  357. <span itemprop="copyrightYear">2020</span>
  358. <span class="with-love">
  359. <i class="fa fa-user"></i>
  360. </span>
  361. <span class="author" itemprop="copyrightHolder">Alex Xiang</span>
  362. </div>
  363. </div>
  364. </footer>
  365. </div>
  366. <script src="/lib/anime.min.js"></script>
  367. <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
  368. <script src="/lib/velocity/velocity.min.js"></script>
  369. <script src="/lib/velocity/velocity.ui.min.js"></script>
  370. <script src="/js/utils.js"></script>
  371. <script src="/js/motion.js"></script>
  372. <script src="/js/schemes/muse.js"></script>
  373. <script src="/js/next-boot.js"></script>
  374. <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex@0/dist/katex.min.css">
  375. <script>
  376. NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  377. NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
  378. var GUEST = ['nick', 'mail', 'link'];
  379. var guest = 'nick,mail,link';
  380. guest = guest.split(',').filter(item => {
  381. return GUEST.includes(item);
  382. });
  383. new Valine({
  384. el : '#valine-comments',
  385. verify : true,
  386. notify : true,
  387. appId : 'BmologYYnRqCv0SLHDeDdA17-gzGzoHsz',
  388. appKey : 'w9mVebFMdCmY6Nh9vfcBGaGt',
  389. placeholder: "Say something.",
  390. avatar : 'mm',
  391. meta : guest,
  392. pageSize : '10' || 10,
  393. visitor : true,
  394. lang : 'en' || 'zh-cn',
  395. path : location.pathname,
  396. recordIP : true,
  397. serverURLs : ''
  398. });
  399. }, window.Valine);
  400. });
  401. </script>
  402. </body>
  403. </html>