-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1052 lines (691 loc) · 38 KB
/
Copy pathindex.html
File metadata and controls
1052 lines (691 loc) · 38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.1.1">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.33/fancybox/fancybox.css" integrity="sha256-gkQVf8UKZgQ0HyuxL/VnacadJ+D2Kox2TCEBuNQg5+w=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"chndk329.github.io","root":"/","images":"/images","scheme":"Pisces","darkmode":false,"version":"8.19.1","exturl":false,"sidebar":{"position":"left","Muse | Mist":320,"Pisces | Gemini":240,"width":240,"display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":null},"fold":{"enable":false,"height":200},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果:${query}","hits_time":"找到 ${hits} 个搜索结果(用时 ${time} 毫秒)","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>
<meta name="description" content="梦想成为大佬的农村做题家">
<meta property="og:type" content="website">
<meta property="og:title" content="小金库">
<meta property="og:url" content="https://chndk329.github.io/index.html">
<meta property="og:site_name" content="小金库">
<meta property="og:description" content="梦想成为大佬的农村做题家">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="闲客">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="https://chndk329.github.io/">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"index.html","title":""}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>小金库</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<div class="column">
<header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">小金库</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger" aria-label="搜索" role="button">
<i class="fa fa-search fa-fw fa-lg"></i>
</div>
</div>
</div>
<nav class="site-nav">
<ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-photos"><a href="/photos/" rel="section"><i class="fa fa-camera fa-fw"></i>相册</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a></li>
<li class="menu-item menu-item-search">
<a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
</a>
</li>
</ul>
</nav>
<div class="search-pop-overlay">
<div class="popup search-popup"><div class="search-header">
<span class="search-icon">
<i class="fa fa-search"></i>
</span>
<div class="search-input-container">
<input autocomplete="off" autocapitalize="off" maxlength="80"
placeholder="搜索..." spellcheck="false"
type="search" class="search-input">
</div>
<span class="popup-btn-close" role="button">
<i class="fa fa-times-circle"></i>
</span>
</div>
<div class="search-result-container no-result">
<div class="search-result-icon">
<i class="fa fa-spinner fa-pulse fa-5x"></i>
</div>
</div>
</div>
</div>
</header>
<aside class="sidebar">
<div class="sidebar-inner sidebar-overview-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="site-author-image" itemprop="image" alt="闲客"
src="/images/avatar.jpg">
<p class="site-author-name" itemprop="name">闲客</p>
<div class="site-description" itemprop="description">梦想成为大佬的农村做题家</div>
</div>
<div class="links-of-author animated">
<span class="links-of-author-item">
<a href="https://github.com/chndk329" title="GitHub → https://github.com/chndk329" rel="noopener me" target="_blank"><i class="fa custom github fa-fw"></i>GitHub</a>
</span>
<span class="links-of-author-item">
<a href="https://space.bilibili.com/504335618?spm_id_from=333.1007.0.0" title="Bilibili → https://space.bilibili.com/504335618?spm_id_from=333.1007.0.0" rel="noopener me" target="_blank"><i class="fa custom bilibili fa-fw"></i>Bilibili</a>
</span>
<span class="links-of-author-item">
<a href="https://leetcode.cn/u/chn-dk" title="LeetCode → https://leetcode.cn/u/chn-dk" rel="noopener me" target="_blank"><i class="fa custom leetcode fa-fw"></i>LeetCode</a>
</span>
<span class="links-of-author-item">
<a href="https://www.luogu.com.cn/user/384326" title="洛谷 → https://www.luogu.com.cn/user/384326" rel="noopener me" target="_blank"><i class="fa custom luogu fa-fw"></i>洛谷</a>
</span>
</div>
</div>
</div>
</div>
</aside>
</div>
<div class="main-inner index posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/23/linux3/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/23/linux3/" class="post-title-link" itemprop="url">Socket网络编程</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-23 13:19:03 / 修改时间:14:00:15" itemprop="dateCreated datePublished" datetime="2024-03-23T13:19:03+08:00">2024-03-23</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="Socket网络编程" href="/2024/03/23/linux3/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::9b99114f7de5481a2f3deaeee6b229b1" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="一、Socket简介"><a href="#一、Socket简介" class="headerlink" title="一、Socket简介"></a>一、Socket简介</h1><h4 id="1、网络中进程间通信"><a href="#1、网络中进程间通信" class="headerlink" title="1、网络中进程间通信"></a>1、网络中进程间通信</h4><p>本机进程使用进程号来区分不同的进程。进程间的通信方式有管道、信号、消息队列、共享内存、信号量等。<br>而网络中进程间通信,首先需要知道进程所在的主机,即网络中唯一的标识即网络层的IP地址,主机上的进程可以通过传输层的协议和端口号识别。</p>
<h4 id="2、Socket原理"><a href="#2、Socket原理" class="headerlink" title="2、Socket原理"></a>2、Socket原理</h4>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/23/linux3/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/22/linux2/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/22/linux2/" class="post-title-link" itemprop="url">生产者消费者模型</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-22 16:11:53 / 修改时间:16:45:17" itemprop="dateCreated datePublished" datetime="2024-03-22T16:11:53+08:00">2024-03-22</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="生产者消费者模型" href="/2024/03/22/linux2/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::b4aa186e97a205da645b7794c88a9edf" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="什么是生产者消费者模型"><a href="#什么是生产者消费者模型" class="headerlink" title="什么是生产者消费者模型"></a>什么是生产者消费者模型</h1><p>生产者-消费者模型($Producer-consumer problem$)是一个非常经典的多线程并发协作的模型,在分布式系统里非常常见。<br><img src="https://s2.loli.net/2024/03/22/3EhHtvqm1TNjfD4.png" alt="523ef8e8b8be4722b1ba88c49bbd671d.png"></p>
<h4 id="这个模型一般由两类线程和一个缓冲区组成来组成:"><a href="#这个模型一般由两类线程和一个缓冲区组成来组成:" class="headerlink" title="这个模型一般由两类线程和一个缓冲区组成来组成:"></a>这个模型一般由两类线程和一个缓冲区组成来组成:</h4><blockquote>
<p>1、生产者线程:生产数据,并把数据放入缓冲区中。<br>2、缓冲区:存放生产者生产的数据的地方。<br>3、消费者线程:从缓冲区里取数据,消费数据。</p>
</blockquote>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/22/linux2/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/16/linux1/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/16/linux1/" class="post-title-link" itemprop="url">C++的静态库与动态库</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-16 21:37:51 / 修改时间:21:42:23" itemprop="dateCreated datePublished" datetime="2024-03-16T21:37:51+08:00">2024-03-16</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="C++的静态库与动态库" href="/2024/03/16/linux1/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::91442de9a55e6c7c04e3d6a630bcd6e6" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>在实际开发中,我们把通用的函数和类分文件编写,称之为库。在其他的程序中,可以使用库中的函数和类。<br>一般来说,通用的函数和类不提供源代码文件(涉及到安全性和商业机密等问题),而是编译成二进制文件。<br>库的二进制文件有两种:静态库和动态库。</p>
<h1 id="一、静态库"><a href="#一、静态库" class="headerlink" title="一、静态库"></a>一、静态库</h1><h4 id="1-制作静态库"><a href="#1-制作静态库" class="headerlink" title="(1) 制作静态库"></a>(1) 制作静态库</h4><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></pre></td><td class="code"><pre><span class="line">g++ -c -o lib库名.a [源代码文件清单] </span><br><span class="line"></span><br><span class="line">-c 表示制作静态库</span><br><span class="line">[lib库名.a] 为静态库文件名,如libpublic.a,库名为<span class="keyword">public</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/16/linux1/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/04/tree_in_tree/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/04/tree_in_tree/" class="post-title-link" itemprop="url">树套树</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-04 20:09:53 / 修改时间:20:13:39" itemprop="dateCreated datePublished" datetime="2024-03-04T20:09:53+08:00">2024-03-04</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="树套树" href="/2024/03/04/tree_in_tree/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::6ab83d79383efda0ff33649b0c492364" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="例题:树套树"><a href="#例题:树套树" class="headerlink" title="例题:树套树"></a>例题:<a target="_blank" rel="noopener" href="https://www.luogu.com.cn/problem/P3380">树套树</a></h1><h4 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h4><p>您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:</p>
<ol>
<li><p>查询 $k$ 在区间内的排名</p>
</li>
<li><p>查询区间内排名为 $k$ 的值</p>
</li>
<li><p>修改某一位值上的数值</p>
</li>
<li><p>查询 $k$ 在区间内的前驱(前驱定义为严格小于 $x$,且最大的数,<strong>若不存在输出 -2147483647</strong>)</p>
</li>
<li><p>查询 $k$ 在区间内的后继(后继定义为严格大于 $x$,且最小的数,<strong>若不存在输出 2147483647</strong>)</p>
</li>
</ol>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/04/tree_in_tree/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/03/splay/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/03/splay/" class="post-title-link" itemprop="url">伸展树</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-03 21:02:13 / 修改时间:21:04:05" itemprop="dateCreated datePublished" datetime="2024-03-03T21:02:13+08:00">2024-03-03</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="伸展树" href="/2024/03/03/splay/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::1768dfd2771dac3598cbc9584e508e0d" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="例题:维护序列"><a href="#例题:维护序列" class="headerlink" title="例题:维护序列"></a>例题:<a target="_blank" rel="noopener" href="https://www.luogu.com.cn/problem/P2042">维护序列</a></h1><h4 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h4><p>请写一个程序,要求维护一个数列,支持以下 $6$ 种操作:</p>
<table>
<thead>
<tr>
<th align="center">编号</th>
<th align="center">名称</th>
<th align="center">格式</th>
<th align="left">说明</th>
</tr>
</thead>
<tbody><tr>
<td align="center">1</td>
<td align="center">插入</td>
<td align="center">$\operatorname{INSERT}\ posi \ tot \ c_1 \ c_2 \cdots c_{tot}$</td>
<td align="left">在当前数列的第 $posi$ 个数字后插入 $tot$ 个数字:$c_1, c_2 \cdots c_{tot}$;若在数列首插入,则 $posi$ 为 $0$</td>
</tr>
<tr>
<td align="center">2</td>
<td align="center">删除</td>
<td align="center">$\operatorname{DELETE} \ posi \ tot$</td>
<td align="left">从当前数列的第 $posi$ 个数字开始连续删除 $tot$ 个数字</td>
</tr>
<tr>
<td align="center">3</td>
<td align="center">修改</td>
<td align="center">$\operatorname{MAKE-SAME} \ posi \ tot \ c$</td>
<td align="left">从当前数列的第 $posi$ 个数字开始的连续 $tot$ 个数字统一修改为 $c$</td>
</tr>
<tr>
<td align="center">4</td>
<td align="center">翻转</td>
<td align="center">$\operatorname{REVERSE} \ posi \ tot$</td>
<td align="left">取出从当前数列的第 $posi$ 个数字开始的 $tot$ 个数字,翻转后放入原来的位置</td>
</tr>
<tr>
<td align="center">5</td>
<td align="center">求和</td>
<td align="center">$\operatorname{GET-SUM} \ posi \ tot$</td>
<td align="left">计算从当前数列的第 $posi$ 个数字开始的 $tot$ 个数字的和并输出</td>
</tr>
<tr>
<td align="center">6</td>
<td align="center">求最大子列和</td>
<td align="center">$\operatorname{MAX-SUM}$</td>
<td align="left">求出当前数列中和最大的一段子列,并输出最大和</td>
</tr>
</tbody></table>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/03/splay/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/03/manacher/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/03/manacher/" class="post-title-link" itemprop="url">$Manacher$算法</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-03 18:10:05" itemprop="dateCreated datePublished" datetime="2024-03-03T18:10:05+08:00">2024-03-03</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-03-04 23:27:04" itemprop="dateModified" datetime="2024-03-04T23:27:04+08:00">2024-03-04</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="$Manacher$算法" href="/2024/03/03/manacher/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::7c47abcbb1a0d0ea65c45fead485ed5a" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="例题:回文串"><a href="#例题:回文串" class="headerlink" title="例题:回文串"></a>例题:<a target="_blank" rel="noopener" href="https://www.dotcpp.com/oj/problem1200.html">回文串</a></h1><p>$Manacher$算法,又叫“马拉车”算法,只适用于在时间复杂度为$O(N)$的情况下求解一个字符串的最长回文子串长度的问题。</p>
<h2 id="一、预处理"><a href="#一、预处理" class="headerlink" title="一、预处理"></a>一、预处理</h2><p>回文串长度个数为奇数,则其对称位置在某个字符。否则在两个字符中间,非常不利于计算回文串长度。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/03/manacher/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/03/hgmq/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/03/hgmq/" class="post-title-link" itemprop="url">回滚莫队</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-03 10:56:41" itemprop="dateCreated datePublished" datetime="2024-03-03T10:56:41+08:00">2024-03-03</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-03-04 20:24:25" itemprop="dateModified" datetime="2024-03-04T20:24:25+08:00">2024-03-04</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="回滚莫队" href="/2024/03/03/hgmq/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::873ba68a823b5b5fd2e6f342daffcb26" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="例题:历史的研究"><a href="#例题:历史的研究" class="headerlink" title="例题:历史的研究"></a>例题:<a target="_blank" rel="noopener" href="https://www.luogu.com.cn/problem/AT_joisc2014_c">历史的研究</a></h1><h4 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h4><p>$IOI$ 国历史研究的第一人——$JOI$ 教授,最近获得了一份被认为是古代 $IOI$ 国的住民写下的日记。$JOI$ 教授为了通过这份日记来研究古代 $IOI$ 国的生活,开始着手调查日记中记载的事件。</p>
<p>日记中记录了连续 $N$ 天发生的事件,大约每天发生一件。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/03/hgmq/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="https://chndk329.github.io/2024/03/02/mq/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.jpg">
<meta itemprop="name" content="闲客">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="小金库">
<meta itemprop="description" content="梦想成为大佬的农村做题家">
</span>
<span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
<meta itemprop="name" content="undefined | 小金库">
<meta itemprop="description" content="">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2024/03/02/mq/" class="post-title-link" itemprop="url">朴素莫队</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2024-03-02 20:49:10" itemprop="dateCreated datePublished" datetime="2024-03-02T20:49:10+08:00">2024-03-02</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2024-03-04 20:23:01" itemprop="dateModified" datetime="2024-03-04T20:23:01+08:00">2024-03-04</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-comment"></i>
</span>
<span class="post-meta-item-text">Changyan:</span>
<a title="朴素莫队" href="/2024/03/02/mq/#SOHUCS" itemprop="discussionUrl">
<span id="sourceId::13d857c32ec7e72a6a9fa2c28b21a0f4" class="cy_cmt_count" itemprop="commentCount"></span>
</a>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h1 id="例题:HH的项链"><a href="#例题:HH的项链" class="headerlink" title="例题:HH的项链"></a>例题:<a target="_blank" rel="noopener" href="https://www.luogu.com.cn/problem/P1972">HH的项链</a></h1><h3 id="题目描述"><a href="#题目描述" class="headerlink" title="题目描述"></a>题目描述</h3><p>$HH$有一串由各种漂亮的贝壳组成的项链。$HH$ 相信不同的贝壳会带来好运,所以每次散步完后,他都会随意取出一段贝壳,思考它们所表达的含义。$HH$ 不断地收集新的贝壳,因此,他的项链变得越来越长。 </p>
<p>有一天,他突然提出了一个问题:某一段贝壳中,包含了多少种不同的贝壳?这个问题很难回答…… 因为项链实在是太长了。于是,他只好求助睿智的你,来解决这个问题。</p>
<!--noindex-->
<div class="post-button">
<a class="btn" href="/2024/03/02/mq/#more" rel="contents">
阅读全文 »
</a>
</div>
<!--/noindex-->
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2024</span>
<span class="with-love">
<i class="fa fa-heart"></i>